import sys

import bisect

input = sys.stdin.readline



n = int(eval(input()))

l = list(map(int, input().split()))

l.sort()

ans = 0

for i in range(n):

    for j in range(i + 1, n):

        check = bisect.bisect_left(l, l[i] + l[j])

        ans += max(0, check - j - 1)

print(ans)

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



from bisect import bisect_left



n = int(readline())

l = sorted(list(map(int, readline().split())))

ans = 0

for i in range(n - 2):

    for j in range(i + 1, n - 1):

        ans += bisect_left(l, l[i] + l[j]) - (j + 1)

print(ans)

import sys
import bisect

input = sys.stdin.readline
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        check = bisect.bisect_left(l, l[i] + l[j])
        ans += max(0, check - j - 1)
print(ans)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
from bisect import bisect_left

n = int(readline())
l = sorted(list(map(int, readline().split())))
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        ans += bisect_left(l, l[i] + l[j]) - (j + 1)
print(ans)

-import bisect -input = sys.stdin.readline -n = int(eval(input())) -l = list(map(int, input().split())) -l.sort() +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10**7) +from bisect import bisect_left + +n = int(readline()) +l = sorted(list(map(int, readline().split()))) -for i in range(n): -    for j in range(i + 1, n): -        check = bisect.bisect_left(l, l[i] + l[j]) -        ans += max(0, check - j - 1) +for i in range(n - 2): +    for j in range(i + 1, n - 1): +        ans += bisect_left(l, l[i] + l[j]) - (j + 1)