import bisect



n = int(eval(input()))



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

ans = 0



for i in range(n):

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

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

    if k > j:

      ans += k - j - 1



print(ans)

import bisect



n = int(eval(input()))



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

ans = 0



for i in range(n):

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

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

    #if k > j:

    ans += k - j - 1



print(ans)

import bisect

n = int(eval(input()))
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        k = bisect.bisect_left(l, l[i] + l[j])
        if k > j:
            ans += k - j - 1
print(ans)

import bisect

n = int(eval(input()))
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        k = bisect.bisect_left(l, l[i] + l[j])
        # if k > j:
        ans += k - j - 1
print(ans)

-        if k > j: -            ans += k - j - 1 +        # if k > j: +        ans += k - j - 1