import itertools   # accumulate, compress, permutations(nPr), combinations(nCr)
import bisect      # bisect_left(insert位置), bisect_right(slice用)
# import math        # factorical（階乗) # hypot(距離)
# import heapq
# from fractions import gcd # Python3.5以前 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # Python3.6以降
# --------------------------------------------------------------

n  = int(input())
bo = list(map(int,input().split()))
 
cnt = 0
bo.sort()
 
for a in range(n-1):
    for b in range(a+1,n):
        cnt += bisect.bisect_left(bo, bo[a]+bo[b]) - (b+1)

print(cnt) import itertools itertools import bisect bisect n  = int(input()) n int(input()) int input() input bo = list(map(int,input().split())) bo list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split cnt = 0 cnt 0 bo.sort() bo.sort bo sort for a in range(n-1):
    for b in range(a+1,n):
        cnt += bisect.bisect_left(bo, bo[a]+bo[b]) - (b+1) a range(n-1) range n-1 n 1 for b in range(a+1,n):
        cnt += bisect.bisect_left(bo, bo[a]+bo[b]) - (b+1) b range(a+1,n) range a+1 a 1 n cnt += bisect.bisect_left(bo, bo[a]+bo[b]) - (b+1) cnt bisect.bisect_left(bo, bo[a]+bo[b]) - (b+1) bisect.bisect_left(bo, bo[a]+bo[b]) bisect.bisect_left bisect bisect_left bo bo[a]+bo[b] bo[a] bo a bo[b] bo b b+1 b 1 print(cnt) print cnt n  = int(input()) int(input()) n bo = list(map(int,input().split())) list(map(int,input().split())) bo cnt = 0 0 cnt cnt += bisect.bisect_left(bo, bo[a]+bo[b]) - (b+1) bisect.bisect_left(bo, bo[a]+bo[b]) - (b+1) cnt
import itertools   # accumulate, compress, permutations(nPr), combinations(nCr)
import bisect      # bisect_left(insert位置), bisect_right(slice用)
# import math        # factorical（階乗) # hypot(距離)
# import heapq
# from fractions import gcd # Python3.5以前 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # Python3.6以降
# --------------------------------------------------------------

n  = int(input())
bo = list(map(int,input().split()))
 
cnt = 0
bo.sort()
 
for a in range(n-1):
    for b in range(a+1,n):
        cnt += bisect.bisect_left(bo, bo[a]+bo[b]) - (b+1)

print(cnt)