import bisect

n = int(input())
ll = list(map(int, input().split()))
ll.sort()

ans = 0
for i in range(n-2):
    e1 = ll[i]
    for j in range(i+1, n-1):
        e2 = ll[j]
        cnt = bisect.bisect_left(ll, e1+e2)
        cnt -= (j+1)
        ans += max(cnt,0)

print(ans)
 import bisect bisect n = int(input()) n int(input()) int input() input ll = list(map(int, input().split())) ll list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ll.sort() ll.sort ll sort ans = 0 ans 0 for i in range(n-2):
    e1 = ll[i]
    for j in range(i+1, n-1):
        e2 = ll[j]
        cnt = bisect.bisect_left(ll, e1+e2)
        cnt -= (j+1)
        ans += max(cnt,0) i range(n-2) range n-2 n 2 e1 = ll[i] e1 ll[i] ll i for j in range(i+1, n-1):
        e2 = ll[j]
        cnt = bisect.bisect_left(ll, e1+e2)
        cnt -= (j+1)
        ans += max(cnt,0) j range(i+1, n-1) range i+1 i 1 n-1 n 1 e2 = ll[j] e2 ll[j] ll j cnt = bisect.bisect_left(ll, e1+e2) cnt bisect.bisect_left(ll, e1+e2) bisect.bisect_left bisect bisect_left ll e1+e2 e1 e2 cnt -= (j+1) cnt j+1 j 1 ans += max(cnt,0) ans max(cnt,0) max cnt 0 print(ans) print ans n = int(input()) int(input()) n ans = 0 0 ans e1 = ll[i] ll[i] e1 ll = list(map(int, input().split())) list(map(int, input().split())) ll ans += max(cnt,0) max(cnt,0) ans cnt = bisect.bisect_left(ll, e1+e2) bisect.bisect_left(ll, e1+e2) cnt cnt -= (j+1) j+1 cnt e2 = ll[j] ll[j] e2
import bisect

n = int(input())
ll = list(map(int, input().split()))
ll.sort()

ans = 0
for i in range(n-2):
    e1 = ll[i]
    for j in range(i+1, n-1):
        e2 = ll[j]
        cnt = bisect.bisect_left(ll, e1+e2)
        cnt -= (j+1)
        ans += max(cnt,0)

print(ans)

