import bisect

n = int(input())
ll = [int(w) for w in input().split()]
ll.sort()

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ans += bisect.bisect_left(ll, ll[i] + ll[j]) - (j + 1)

print(ans) import bisect bisect n = int(input()) n int(input()) int input() input int(w) for w in input().split() for w in input().split() w input().split() ().split () input split for w in input().split() int(w) int w ll = [int(w) for w in input().split()] ll [int(w) for w in input().split()] ll.sort() ll.sort ll sort ans = 0 ans 0 for i in range(n):
    for j in range(i + 1, n):
        ans += bisect.bisect_left(ll, ll[i] + ll[j]) - (j + 1) i range(n) range n for j in range(i + 1, n):
        ans += bisect.bisect_left(ll, ll[i] + ll[j]) - (j + 1) j range(i + 1, n) range i + 1 i 1 n ans += bisect.bisect_left(ll, ll[i] + ll[j]) - (j + 1) ans bisect.bisect_left(ll, ll[i] + ll[j]) - (j + 1) bisect.bisect_left(ll, ll[i] + ll[j]) bisect.bisect_left bisect bisect_left ll ll[i] + ll[j] ll[i] ll i ll[j] ll j j + 1 j 1 print(ans) print ans ans = 0 0 ans ll = [int(w) for w in input().split()] [int(w) for w in input().split()] ll n = int(input()) int(input()) n ans += bisect.bisect_left(ll, ll[i] + ll[j]) - (j + 1) bisect.bisect_left(ll, ll[i] + ll[j]) - (j + 1) ans
import bisect

n = int(input())
ll = [int(w) for w in input().split()]
ll.sort()

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ans += bisect.bisect_left(ll, ll[i] + ll[j]) - (j + 1)

print(ans)
