import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)

cnt = 0

for i in range(n):
    for j in range(i+1, n):
        x = bisect.bisect_left(l, l[i]+l[j])
        cnt += x-j-1

print(cnt) 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 = sorted(l) l sorted(l) sorted l cnt = 0 cnt 0 for i in range(n):
    for j in range(i+1, n):
        x = bisect.bisect_left(l, l[i]+l[j])
        cnt += x-j-1 i range(n) range n for j in range(i+1, n):
        x = bisect.bisect_left(l, l[i]+l[j])
        cnt += x-j-1 j range(i+1, n) range i+1 i 1 n x = bisect.bisect_left(l, l[i]+l[j]) x 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 cnt += x-j-1 cnt x-j-1 x-j x j 1 print(cnt) print cnt l = sorted(l) sorted(l) l n = int(input()) int(input()) n cnt = 0 0 cnt l = list(map(int, input().split())) list(map(int, input().split())) l x = bisect.bisect_left(l, l[i]+l[j]) bisect.bisect_left(l, l[i]+l[j]) x cnt += x-j-1 x-j-1 cnt
import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)

cnt = 0

for i in range(n):
    for j in range(i+1, n):
        x = bisect.bisect_left(l, l[i]+l[j])
        cnt += x-j-1

print(cnt)