import bisect

N = int(input())
L = sorted(map(int, input().split()))
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = bisect.bisect_left(L, L[i] + L[j])
        if k > j:
            ans += k - j - 1
print(ans) import bisect bisect N = int(input()) N int(input()) int input() input L = sorted(map(int, input().split())) L sorted(map(int, input().split())) sorted map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = bisect.bisect_left(L, L[i] + L[j])
        if k > j:
            ans += k - j - 1 i range(N - 2) range N - 2 N 2 for j in range(i + 1, N - 1):
        k = bisect.bisect_left(L, L[i] + L[j])
        if k > j:
            ans += k - j - 1 j range(i + 1, N - 1) range i + 1 i 1 N - 1 N 1 k = bisect.bisect_left(L, L[i] + L[j]) k 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 k > j:
            ans += k - j - 1 k > j k j ans += k - j - 1 ans k - j - 1 k - j k j 1 print(ans) print ans ans = 0 0 ans N = int(input()) int(input()) N k = bisect.bisect_left(L, L[i] + L[j]) bisect.bisect_left(L, L[i] + L[j]) k ans += k - j - 1 k - j - 1 ans L = sorted(map(int, input().split())) sorted(map(int, input().split())) L
import bisect

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