import bisect
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0          
for ai in range(n):
  for bi in range(ai+1,n):
    ci = bisect.bisect_left(l,l[ai]+l[bi])
    if ci>bi:
      ans += ci-bi-1
print(ans) import bisect bisect 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 ai in range(n):
  for bi in range(ai+1,n):
    ci = bisect.bisect_left(l,l[ai]+l[bi])
    if ci>bi:
      ans += ci-bi-1 ai range(n) range n for bi in range(ai+1,n):
    ci = bisect.bisect_left(l,l[ai]+l[bi])
    if ci>bi:
      ans += ci-bi-1 bi range(ai+1,n) range ai+1 ai 1 n ci = bisect.bisect_left(l,l[ai]+l[bi]) ci bisect.bisect_left(l,l[ai]+l[bi]) bisect.bisect_left bisect bisect_left l l[ai]+l[bi] l[ai] l ai l[bi] l bi if ci>bi:
      ans += ci-bi-1 ci>bi ci bi ans += ci-bi-1 ans ci-bi-1 ci-bi ci bi 1 print(ans) print ans n = int(input()) int(input()) n l = sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) l ans += ci-bi-1 ci-bi-1 ans ans = 0 0 ans ci = bisect.bisect_left(l,l[ai]+l[bi]) bisect.bisect_left(l,l[ai]+l[bi]) ci
import bisect
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0          
for ai in range(n):
  for bi in range(ai+1,n):
    ci = bisect.bisect_left(l,l[ai]+l[bi])
    if ci>bi:
      ans += ci-bi-1
print(ans)