import sys
readline = sys.stdin.readline

N = int(readline())
L = list(map(int,readline().split()))
L = sorted(L)

# 2本固定すると、もう一本として選べるのは、2本の和より長いものだけ
# これを二分探索で数える

#print(L)
import bisect
ans = 0
for i in range(N - 1):
  for j in range(i + 1,N):
    limit = L[i] + L[j]
    ok = bisect.bisect_left(L, limit)
#    print("i",i,"j",j,"L[i]",L[i],"L[j]",L[j],"limit",limit,"ok",ok,"ok - j",ok - 1 - j)
    ans += ok - 1 - j
        
print(ans) import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline N = int(readline()) N int(readline()) int readline() readline L = list(map(int,readline().split())) L list(map(int,readline().split())) list map(int,readline().split()) map int readline().split() ().split () readline split L = sorted(L) L sorted(L) sorted L import bisect bisect ans = 0 ans 0 for i in range(N - 1):
  for j in range(i + 1,N):
    limit = L[i] + L[j]
    ok = bisect.bisect_left(L, limit)
#    print("i",i,"j",j,"L[i]",L[i],"L[j]",L[j],"limit",limit,"ok",ok,"ok - j",ok - 1 - j)
    ans += ok - 1 - j
         i range(N - 1) range N - 1 N 1 for j in range(i + 1,N):
    limit = L[i] + L[j]
    ok = bisect.bisect_left(L, limit)
#    print("i",i,"j",j,"L[i]",L[i],"L[j]",L[j],"limit",limit,"ok",ok,"ok - j",ok - 1 - j)
    ans += ok - 1 - j
         j range(i + 1,N) range i + 1 i 1 N limit = L[i] + L[j] limit L[i] + L[j] L[i] L i L[j] L j ok = bisect.bisect_left(L, limit) ok bisect.bisect_left(L, limit) bisect.bisect_left bisect bisect_left L limit ans += ok - 1 - j ans ok - 1 - j ok - 1 ok 1 j print(ans) print ans ans += ok - 1 - j ok - 1 - j ans L = list(map(int,readline().split())) list(map(int,readline().split())) L ans = 0 0 ans ok = bisect.bisect_left(L, limit) bisect.bisect_left(L, limit) ok L = sorted(L) sorted(L) L readline = sys.stdin.readline sys.stdin.readline readline N = int(readline()) int(readline()) N limit = L[i] + L[j] L[i] + L[j] limit
import sys
readline = sys.stdin.readline

N = int(readline())
L = list(map(int,readline().split()))
L = sorted(L)

# 2本固定すると、もう一本として選べるのは、2本の和より長いものだけ
# これを二分探索で数える

#print(L)
import bisect
ans = 0
for i in range(N - 1):
  for j in range(i + 1,N):
    limit = L[i] + L[j]
    ok = bisect.bisect_left(L, limit)
#    print("i",i,"j",j,"L[i]",L[i],"L[j]",L[j],"limit",limit,"ok",ok,"ok - j",ok - 1 - j)
    ans += ok - 1 - j
        
print(ans)