import bisect
N = int(input())
L = list(map(int, input().split()))
ans = 0
L.sort()
for a_i in range(N-2):
    for b_j in range(a_i+1, N-1):
        c_idx = bisect.bisect_left(L, L[a_i]+L[b_j])
        if c_idx > b_j:
            ans += c_idx - b_j - 1
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 ans = 0 ans 0 L.sort() L.sort L sort for a_i in range(N-2):
    for b_j in range(a_i+1, N-1):
        c_idx = bisect.bisect_left(L, L[a_i]+L[b_j])
        if c_idx > b_j:
            ans += c_idx - b_j - 1 a_i range(N-2) range N-2 N 2 for b_j in range(a_i+1, N-1):
        c_idx = bisect.bisect_left(L, L[a_i]+L[b_j])
        if c_idx > b_j:
            ans += c_idx - b_j - 1 b_j range(a_i+1, N-1) range a_i+1 a_i 1 N-1 N 1 c_idx = bisect.bisect_left(L, L[a_i]+L[b_j]) c_idx bisect.bisect_left(L, L[a_i]+L[b_j]) bisect.bisect_left bisect bisect_left L L[a_i]+L[b_j] L[a_i] L a_i L[b_j] L b_j if c_idx > b_j:
            ans += c_idx - b_j - 1 c_idx > b_j c_idx b_j ans += c_idx - b_j - 1 ans c_idx - b_j - 1 c_idx - b_j c_idx b_j 1 print(ans) print ans ans = 0 0 ans L = list(map(int, input().split())) list(map(int, input().split())) L c_idx = bisect.bisect_left(L, L[a_i]+L[b_j]) bisect.bisect_left(L, L[a_i]+L[b_j]) c_idx N = int(input()) int(input()) N ans += c_idx - b_j - 1 c_idx - b_j - 1 ans
import bisect
N = int(input())
L = list(map(int, input().split()))
ans = 0
L.sort()
for a_i in range(N-2):
    for b_j in range(a_i+1, N-1):
        c_idx = bisect.bisect_left(L, L[a_i]+L[b_j])
        if c_idx > b_j:
            ans += c_idx - b_j - 1
print(ans)