from bisect import bisect_left
 
n = int(input())
l = sorted(list(map(int,input().split())))

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

print(ans) from bisect import bisect_left n = int(input()) n int(input()) int input() input l = sorted(list(map(int,input().split()))) l sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans = 0 ans 0 for i in range(n-2):
    for j in range(i+1,n-1):
        k = bisect_left(l,l[i]+l[j])
        ans += k - j - 1 i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
        k = bisect_left(l,l[i]+l[j])
        ans += k - j - 1 j range(i+1,n-1) range i+1 i 1 n-1 n 1 k = bisect_left(l,l[i]+l[j]) k bisect_left(l,l[i]+l[j]) bisect_left l l[i]+l[j] l[i] l i l[j] l 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 k = bisect_left(l,l[i]+l[j]) bisect_left(l,l[i]+l[j]) k l = sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) l n = int(input()) int(input()) n ans = 0 0 ans
from bisect import bisect_left
 
n = int(input())
l = sorted(list(map(int,input().split())))

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

print(ans)