import bisect



N = int(eval(input()))

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



SL = sorted(L)

ans = 0

for i in range(N):

  if i+1 == N-1:

    break

  a = SL[i]

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

    b = SL[j]

    c_max = bisect.bisect_left(SL, a+b)

    ans += c_max - (j+1)



print(ans)
import sys

input = sys.stdin.readline

import collections

import bisect



def main():

    n = int(eval(input()))

    l = input_list()

    l.sort()

    ans = 0

    for i in range(n-2):

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

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

            num = ind - 1 - j

            ans += num

    print(ans)





def input_list():

    return list(map(int, input().split()))





def input_list_str():

    return list(map(str, input().split()))





if __name__ == "__main__":

    main()

import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
SL = sorted(L)
ans = 0
for i in range(N):
    if i + 1 == N - 1:
        break
    a = SL[i]
    for j in range(i + 1, N):
        b = SL[j]
        c_max = bisect.bisect_left(SL, a + b)
        ans += c_max - (j + 1)
print(ans)

import sys

input = sys.stdin.readline
import collections
import bisect


def main():
    n = int(eval(input()))
    l = input_list()
    l.sort()
    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            ind = bisect.bisect_left(l, l[i] + l[j])
            num = ind - 1 - j
            ans += num
    print(ans)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

+import sys + +input = sys.stdin.readline +import collections -N = int(eval(input())) -L = list(map(int, input().split())) -SL = sorted(L) -ans = 0 -for i in range(N): -    if i + 1 == N - 1: -        break -    a = SL[i] -    for j in range(i + 1, N): -        b = SL[j] -        c_max = bisect.bisect_left(SL, a + b) -        ans += c_max - (j + 1) -print(ans) + +def main(): +    n = int(eval(input())) +    l = input_list() +    l.sort() +    ans = 0 +    for i in range(n - 2): +        for j in range(i + 1, n - 1): +            ind = bisect.bisect_left(l, l[i] + l[j]) +            num = ind - 1 - j +            ans += num +    print(ans) + + +def input_list(): +    return list(map(int, input().split())) + + +def input_list_str(): +    return list(map(str, input().split())) + + +if __name__ == "__main__": +    main()