from bisect import bisect_left
n = int(input())
m=list(map(int,input().split()))
k=0
m.sort()
for i in range(n-2):
    for j in range(i+1,n-1):
        z=m[i]+m[j]
        l=bisect_left(m,z)
        k+=l-j-1
print(k) from bisect import bisect_left n = int(input()) n int(input()) int input() input m=list(map(int,input().split())) m list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k=0 k 0 m.sort() m.sort m sort for i in range(n-2):
    for j in range(i+1,n-1):
        z=m[i]+m[j]
        l=bisect_left(m,z)
        k+=l-j-1 i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
        z=m[i]+m[j]
        l=bisect_left(m,z)
        k+=l-j-1 j range(i+1,n-1) range i+1 i 1 n-1 n 1 z=m[i]+m[j] z m[i]+m[j] m[i] m i m[j] m j l=bisect_left(m,z) l bisect_left(m,z) bisect_left m z k+=l-j-1 k l-j-1 l-j l j 1 print(k) print k z=m[i]+m[j] m[i]+m[j] z m=list(map(int,input().split())) list(map(int,input().split())) m k+=l-j-1 l-j-1 k k=0 0 k l=bisect_left(m,z) bisect_left(m,z) l n = int(input()) int(input()) n
from bisect import bisect_left
n = int(input())
m=list(map(int,input().split()))
k=0
m.sort()
for i in range(n-2):
    for j in range(i+1,n-1):
        z=m[i]+m[j]
        l=bisect_left(m,z)
        k+=l-j-1
print(k)