import bisect
N = int(input())
L = sorted([int(i) for i in input().split()])
ans = 0

for j in range(N-2):
    for k in range(j+1,N-1):
        S = L[j] + L[k]
        a = bisect.bisect_left(L, S)
        ans += a - 1 - k 

print(ans) import bisect bisect N = int(input()) N int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i L = sorted([int(i) for i in input().split()]) L sorted([int(i) for i in input().split()]) sorted [int(i) for i in input().split()] ans = 0 ans 0 for j in range(N-2):
    for k in range(j+1,N-1):
        S = L[j] + L[k]
        a = bisect.bisect_left(L, S)
        ans += a - 1 - k  j range(N-2) range N-2 N 2 for k in range(j+1,N-1):
        S = L[j] + L[k]
        a = bisect.bisect_left(L, S)
        ans += a - 1 - k  k range(j+1,N-1) range j+1 j 1 N-1 N 1 S = L[j] + L[k] S L[j] + L[k] L[j] L j L[k] L k a = bisect.bisect_left(L, S) a bisect.bisect_left(L, S) bisect.bisect_left bisect bisect_left L S ans += a - 1 - k ans a - 1 - k a - 1 a 1 k print(ans) print ans a = bisect.bisect_left(L, S) bisect.bisect_left(L, S) a ans += a - 1 - k a - 1 - k ans ans = 0 0 ans S = L[j] + L[k] L[j] + L[k] S N = int(input()) int(input()) N L = sorted([int(i) for i in input().split()]) sorted([int(i) for i in input().split()]) L
import bisect
N = int(input())
L = sorted([int(i) for i in input().split()])
ans = 0

for j in range(N-2):
    for k in range(j+1,N-1):
        S = L[j] + L[k]
        a = bisect.bisect_left(L, S)
        ans += a - 1 - k 

print(ans)
