import bisect

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

n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        if j == n-1:
            continue
        x = l[i] + l[j]
        cnt += bisect.bisect_left(l[j+1:], x)
print(cnt)