import bisect


N = int(input())
str_l = input()
num = 0
L = []
for v in str_l.split(' '):
    L.append(int(v))

L.sort()
for i in range(N - 1):
    a = L[i]
    for j in range(i, N - 2):
        b = L[j + 1]
        index = bisect.bisect_left(L[j + 2:], a + b)
        num += index
        # for k in range(0, index):
        #     c = (L[j + 2:])[k]
        #     if b + c > a and a + c > b:
        #         num += 1

print(num) import bisect bisect N = int(input()) N int(input()) int input() input str_l = input() str_l input() input num = 0 num 0 L = [] L [] for v in str_l.split(' '):
    L.append(int(v)) v str_l.split(' ') str_l.split str_l split ' ' L.append(int(v)) L.append L append int(v) int v L.sort() L.sort L sort for i in range(N - 1):
    a = L[i]
    for j in range(i, N - 2):
        b = L[j + 1]
        index = bisect.bisect_left(L[j + 2:], a + b)
        num += index
        # for k in range(0, index):
        #     c = (L[j + 2:])[k]
        #     if b + c > a and a + c > b:
        #         num += 1 i range(N - 1) range N - 1 N 1 a = L[i] a L[i] L i for j in range(i, N - 2):
        b = L[j + 1]
        index = bisect.bisect_left(L[j + 2:], a + b)
        num += index
        # for k in range(0, index):
        #     c = (L[j + 2:])[k]
        #     if b + c > a and a + c > b:
        #         num += 1 j range(i, N - 2) range i N - 2 N 2 b = L[j + 1] b L[j + 1] L j + 1 j 1 index = bisect.bisect_left(L[j + 2:], a + b) index bisect.bisect_left(L[j + 2:], a + b) bisect.bisect_left bisect bisect_left L[j + 2:] L j + 2: j + 2 j 2 a + b a b num += index num index print(num) print num b = L[j + 1] L[j + 1] b str_l = input() input() str_l num += index index num N = int(input()) int(input()) N a = L[i] L[i] a L = [] [] L index = bisect.bisect_left(L[j + 2:], a + b) bisect.bisect_left(L[j + 2:], a + b) index num = 0 0 num
import bisect


N = int(input())
str_l = input()
num = 0
L = []
for v in str_l.split(' '):
    L.append(int(v))

L.sort()
for i in range(N - 1):
    a = L[i]
    for j in range(i, N - 2):
        b = L[j + 1]
        index = bisect.bisect_left(L[j + 2:], a + b)
        num += index
        # for k in range(0, index):
        #     c = (L[j + 2:])[k]
        #     if b + c > a and a + c > b:
        #         num += 1

print(num)