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