import itertools
 
n = int(input())
A = list(map(int,input().split()))
A.sort()
 
def binary_search(l,r,v):
    while r >= l:
        h = (l+r) // 2
        if A[h] < v:
            l = h+1
        else:
            r = h-1
    return r
 
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        a = binary_search(j,n-1,A[i]+A[j])
        ans += a-j
 
print(ans) import itertools itertools n = int(input()) n int(input()) int input() input A = list(map(int,input().split())) A list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split A.sort() A.sort A sort def binary_search(l,r,v):
    while r >= l:
        h = (l+r) // 2
        if A[h] < v:
            l = h+1
        else:
            r = h-1
    return r
  binary_search while r >= l:
        h = (l+r) // 2
        if A[h] < v:
            l = h+1
        else:
            r = h-1
     r >= l r l h = (l+r) // 2 h (l+r) // 2 l+r l r 2 if A[h] < v:
            l = h+1
        else:
            r = h-1
     A[h] < v A[h] A h v l = h+1 l h+1 h 1 r = h-1 r h-1 h 1 return r r l l r r v v ans = 0 ans 0 for i in range(n-2):
    for j in range(i+1,n-1):
        a = binary_search(j,n-1,A[i]+A[j])
        ans += a-j
  i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
        a = binary_search(j,n-1,A[i]+A[j])
        ans += a-j
  j range(i+1,n-1) range i+1 i 1 n-1 n 1 a = binary_search(j,n-1,A[i]+A[j]) a binary_search(j,n-1,A[i]+A[j]) binary_search j n-1 n 1 A[i]+A[j] A[i] A i A[j] A j ans += a-j ans a-j a j print(ans) print ans n = int(input()) int(input()) n def binary_search(l,r,v):
    while r >= l:
        h = (l+r) // 2
        if A[h] < v:
            l = h+1
        else:
            r = h-1
    return r
  def binary_search(l,r,v):
    while r >= l:
        h = (l+r) // 2
        if A[h] < v:
            l = h+1
        else:
            r = h-1
    return r
  binary_search a = binary_search(j,n-1,A[i]+A[j]) binary_search(j,n-1,A[i]+A[j]) a A = list(map(int,input().split())) list(map(int,input().split())) A ans = 0 0 ans ans += a-j a-j ans
import itertools
 
n = int(input())
A = list(map(int,input().split()))
A.sort()
 
def binary_search(l,r,v):
    while r >= l:
        h = (l+r) // 2
        if A[h] < v:
            l = h+1
        else:
            r = h-1
    return r
 
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        a = binary_search(j,n-1,A[i]+A[j])
        ans += a-j
 
print(ans)