import itertools
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0

for i in range(len(l)-2):
  for j in range(i+1,len(l)):
    k = bisect.bisect_left(l, l[i]+l[j])
    if k > j:
      ans += k - j -1

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

for i in range(len(l)-2):
  for j in range(i+1,len(l)):
    k = bisect.bisect_left(l, l[i]+l[j])
    if k > j:
      ans += k - j -1

print(ans)