from bisect import bisect
from bisect import bisect_right
from bisect import bisect_left
 
N = int(input())
L = list(map(int, input().split()))
L.sort()
#print(L)
 
cnt = 0
for i in range(N):
  for j in range(i+1, N):
    s = L[i] + L[j]
    x = bisect_left(L, s)
    #print((L[i], L[j]), s, x)
    cnt += max(x - j - 1, 0)
print(cnt) from bisect import bisect from bisect import bisect_right from bisect import bisect_left 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 cnt = 0 cnt 0 for i in range(N):
  for j in range(i+1, N):
    s = L[i] + L[j]
    x = bisect_left(L, s)
    #print((L[i], L[j]), s, x)
    cnt += max(x - j - 1, 0) i range(N) range N for j in range(i+1, N):
    s = L[i] + L[j]
    x = bisect_left(L, s)
    #print((L[i], L[j]), s, x)
    cnt += max(x - j - 1, 0) j range(i+1, N) range i+1 i 1 N s = L[i] + L[j] s L[i] + L[j] L[i] L i L[j] L j x = bisect_left(L, s) x bisect_left(L, s) bisect_left L s cnt += max(x - j - 1, 0) cnt max(x - j - 1, 0) max x - j - 1 x - j x j 1 0 print(cnt) print cnt x = bisect_left(L, s) bisect_left(L, s) x cnt = 0 0 cnt s = L[i] + L[j] L[i] + L[j] s L = list(map(int, input().split())) list(map(int, input().split())) L N = int(input()) int(input()) N cnt += max(x - j - 1, 0) max(x - j - 1, 0) cnt
from bisect import bisect
from bisect import bisect_right
from bisect import bisect_left
 
N = int(input())
L = list(map(int, input().split()))
L.sort()
#print(L)
 
cnt = 0
for i in range(N):
  for j in range(i+1, N):
    s = L[i] + L[j]
    x = bisect_left(L, s)
    #print((L[i], L[j]), s, x)
    cnt += max(x - j - 1, 0)
print(cnt)