import sys
import bisect
N = int(input())
L = list(map(int, input().split()))
LS = sorted(L)
ans = 0
for i in range(N):
  for j in range(N):
    if i < j:
      index = bisect.bisect_left(LS,LS[i]+LS[j])
      ans += index-j-1 

print(ans) import sys sys 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 LS = sorted(L) LS sorted(L) sorted L ans = 0 ans 0 for i in range(N):
  for j in range(N):
    if i < j:
      index = bisect.bisect_left(LS,LS[i]+LS[j])
      ans += index-j-1  i range(N) range N for j in range(N):
    if i < j:
      index = bisect.bisect_left(LS,LS[i]+LS[j])
      ans += index-j-1  j range(N) range N if i < j:
      index = bisect.bisect_left(LS,LS[i]+LS[j])
      ans += index-j-1  i < j i j index = bisect.bisect_left(LS,LS[i]+LS[j]) index bisect.bisect_left(LS,LS[i]+LS[j]) bisect.bisect_left bisect bisect_left LS LS[i]+LS[j] LS[i] LS i LS[j] LS j ans += index-j-1 ans index-j-1 index-j index j 1 print(ans) print ans L = list(map(int, input().split())) list(map(int, input().split())) L LS = sorted(L) sorted(L) LS ans += index-j-1 index-j-1 ans index = bisect.bisect_left(LS,LS[i]+LS[j]) bisect.bisect_left(LS,LS[i]+LS[j]) index N = int(input()) int(input()) N ans = 0 0 ans
import sys
import bisect
N = int(input())
L = list(map(int, input().split()))
LS = sorted(L)
ans = 0
for i in range(N):
  for j in range(N):
    if i < j:
      index = bisect.bisect_left(LS,LS[i]+LS[j])
      ans += index-j-1 

print(ans)