import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N-2):
  for j in range(i+2, N):
    a, b = L[i], L[j]
    right = bisect.bisect_right(L, b-a)
    left = max(right, i+1)
    ans += j - left
print(ans) 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(N-2):
  for j in range(i+2, N):
    a, b = L[i], L[j]
    right = bisect.bisect_right(L, b-a)
    left = max(right, i+1)
    ans += j - left i range(N-2) range N-2 N 2 for j in range(i+2, N):
    a, b = L[i], L[j]
    right = bisect.bisect_right(L, b-a)
    left = max(right, i+1)
    ans += j - left j range(i+2, N) range i+2 i 2 N a, b = L[i], L[j] a L[i] L i b L[j] L j right = bisect.bisect_right(L, b-a) right bisect.bisect_right(L, b-a) bisect.bisect_right bisect bisect_right L b-a b a left = max(right, i+1) left max(right, i+1) max right i+1 i 1 ans += j - left ans j - left j left print(ans) print ans right = bisect.bisect_right(L, b-a) bisect.bisect_right(L, b-a) right left = max(right, i+1) max(right, i+1) left ans += j - left j - left ans ans = 0 0 ans a, b = L[i], L[j] L[i] a L = list(map(int, input().split())) list(map(int, input().split())) L N = int(input()) int(input()) N b = L[i], L[j] L[j] b
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N-2):
  for j in range(i+2, N):
    a, b = L[i], L[j]
    right = bisect.bisect_right(L, b-a)
    left = max(right, i+1)
    ans += j - left
print(ans)