import bisect

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        c_i = bisect.bisect_left(l, l[i]+l[j])
        if c_i > j:
            ans += c_i - j - 1
        else:
            continue
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 ans = 0 ans 0 l.sort() l.sort l sort for i in range(n-2):
    for j in range(i+1, n-1):
        c_i = bisect.bisect_left(l, l[i]+l[j])
        if c_i > j:
            ans += c_i - j - 1
        else:
            continue i range(n-2) range n-2 n 2 for j in range(i+1, n-1):
        c_i = bisect.bisect_left(l, l[i]+l[j])
        if c_i > j:
            ans += c_i - j - 1
        else:
            continue j range(i+1, n-1) range i+1 i 1 n-1 n 1 c_i = bisect.bisect_left(l, l[i]+l[j]) c_i bisect.bisect_left(l, l[i]+l[j]) bisect.bisect_left bisect bisect_left l l[i]+l[j] l[i] l i l[j] l j if c_i > j:
            ans += c_i - j - 1
        else:
            continue c_i > j c_i j ans += c_i - j - 1 ans c_i - j - 1 c_i - j c_i j 1 continue print(ans) print ans c_i = bisect.bisect_left(l, l[i]+l[j]) bisect.bisect_left(l, l[i]+l[j]) c_i ans = 0 0 ans l = list(map(int, input().split())) list(map(int, input().split())) l n = int(input()) int(input()) n ans += c_i - j - 1 c_i - j - 1 ans
import bisect

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        c_i = bisect.bisect_left(l, l[i]+l[j])
        if c_i > j:
            ans += c_i - j - 1
        else:
            continue
print(ans)