from itertools import combinations
from bisect import *
def max2(x,y):
    return x if x > y else y
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i, j in combinations(range(N), 2):
    a, b = L[i], L[j]
    res += max2(bisect_left(L, a+b) -1 - j, 0)
print(res) from itertools import combinations from bisect import * def max2(x,y):
    return x if x > y else y max2 return x if x > y else y x if x > y else y x > y x y x y x x y y N = int(input()) N int(input()) int input() input L = list(map(int, input().split())) L list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L.sort() L.sort L sort res = 0 res 0 for i, j in combinations(range(N), 2):
    a, b = L[i], L[j]
    res += max2(bisect_left(L, a+b) -1 - j, 0) i j combinations(range(N), 2) combinations range(N) range N 2 a, b = L[i], L[j] a L[i] L i b L[j] L j res += max2(bisect_left(L, a+b) -1 - j, 0) res max2(bisect_left(L, a+b) -1 - j, 0) max2 bisect_left(L, a+b) -1 - j bisect_left(L, a+b) -1 bisect_left(L, a+b) bisect_left L a+b a b 1 j 0 print(res) print res res = 0 0 res N = int(input()) int(input()) N def max2(x,y):
    return x if x > y else y def max2(x,y):
    return x if x > y else y max2 res += max2(bisect_left(L, a+b) -1 - j, 0) max2(bisect_left(L, a+b) -1 - j, 0) res b = L[i], L[j] L[j] b L = list(map(int, input().split())) list(map(int, input().split())) L a, b = L[i], L[j] L[i] a
from itertools import combinations
from bisect import *
def max2(x,y):
    return x if x > y else y
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i, j in combinations(range(N), 2):
    a, b = L[i], L[j]
    res += max2(bisect_left(L, a+b) -1 - j, 0)
print(res)