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