import sys
import bisect

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

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        l = L[i] + L[j]
        p = bisect.bisect_left(L, l)
        # print(p)
        ans += p - j - 1

print(ans) import sys sys import bisect bisect input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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-2):
    for j in range(i+1, N-1):
        l = L[i] + L[j]
        p = bisect.bisect_left(L, l)
        # print(p)
        ans += p - j - 1 i range(N-2) range N-2 N 2 for j in range(i+1, N-1):
        l = L[i] + L[j]
        p = bisect.bisect_left(L, l)
        # print(p)
        ans += p - j - 1 j range(i+1, N-1) range i+1 i 1 N-1 N 1 l = L[i] + L[j] l L[i] + L[j] L[i] L i L[j] L j p = bisect.bisect_left(L, l) p bisect.bisect_left(L, l) bisect.bisect_left bisect bisect_left L l ans += p - j - 1 ans p - j - 1 p - j p j 1 print(ans) print ans p = bisect.bisect_left(L, l) bisect.bisect_left(L, l) p input = sys.stdin.readline sys.stdin.readline input L = list(map(int, input().split())) list(map(int, input().split())) L N = int(input()) int(input()) N l = L[i] + L[j] L[i] + L[j] l ans = 0 0 ans ans += p - j - 1 p - j - 1 ans
import sys
import bisect

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

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        l = L[i] + L[j]
        p = bisect.bisect_left(L, l)
        # print(p)
        ans += p - j - 1

print(ans)