import bisect

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

ans = 0

for i in range(N - 1, 1, -1):
    for j in range(i - 1, 0, -1):
        x = bisect.bisect(L, L[i] - L[j])
        ans += max((j - x), 0)

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

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

ans = 0

for i in range(N - 1, 1, -1):
    for j in range(i - 1, 0, -1):
        x = bisect.bisect(L, L[i] - L[j])
        ans += max((j - x), 0)

print(ans)
