from bisect import bisect_left

n = int(input())
a = list(map(int,input().split()))
a.sort()

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect_left(a,a[i]+a[j])
        ans += ind-j-1

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

n = int(input())
a = list(map(int,input().split()))
a.sort()

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect_left(a,a[i]+a[j])
        ans += ind-j-1

print(ans)