from bisect import bisect_left
N = int(input())
A = sorted(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        r = bisect_left(A, A[i]+A[j])
        ans += r-(j+1)

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

ans = 0
for i in range(N):
    for j in range(i+1, N):
        r = bisect_left(A, A[i]+A[j])
        ans += r-(j+1)

print(ans)
