# https://takeg.hatenadiary.jp/entry/2019/11/22/212816
# https://drken1215.hatenablog.com/entry/2019/10/20/032700

import bisect

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

ans = 0

for a in range(N):
    for b in range(a+1, N):
        c = bisect.bisect_left(L, L[a] + L[b])
        # print(a, b, c)
        ans += max(c-(b+1), 0)
        # print(ans)

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 a in range(N):
    for b in range(a+1, N):
        c = bisect.bisect_left(L, L[a] + L[b])
        # print(a, b, c)
        ans += max(c-(b+1), 0)
        # print(ans) a range(N) range N for b in range(a+1, N):
        c = bisect.bisect_left(L, L[a] + L[b])
        # print(a, b, c)
        ans += max(c-(b+1), 0)
        # print(ans) b range(a+1, N) range a+1 a 1 N c = bisect.bisect_left(L, L[a] + L[b]) c bisect.bisect_left(L, L[a] + L[b]) bisect.bisect_left bisect bisect_left L L[a] + L[b] L[a] L a L[b] L b ans += max(c-(b+1), 0) ans max(c-(b+1), 0) max c-(b+1) c b+1 b 1 0 print(ans) print ans c = bisect.bisect_left(L, L[a] + L[b]) bisect.bisect_left(L, L[a] + L[b]) c ans = 0 0 ans L = list(map(int, input().split())) list(map(int, input().split())) L N = int(input()) int(input()) N ans += max(c-(b+1), 0) max(c-(b+1), 0) ans
# https://takeg.hatenadiary.jp/entry/2019/11/22/212816
# https://drken1215.hatenablog.com/entry/2019/10/20/032700

import bisect

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

ans = 0

for a in range(N):
    for b in range(a+1, N):
        c = bisect.bisect_left(L, L[a] + L[b])
        # print(a, b, c)
        ans += max(c-(b+1), 0)
        # print(ans)

print(ans)
