n = int(eval(input()))

L = sorted(list(map(int,input().split())))

import bisect

ans = 0

#print(L)

for a in range(n-2):

    for b in range(a+1,n-1):

        p = bisect.bisect_left(L,L[a] + L[b])

        #print(bisect.bisect_left(L,L[a]+L[b]),"-",L[a] + L[b])

        ans += p - (b+1)

print(ans)

#from statistics import median

#import collections

#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

from fractions import gcd

from itertools import combinations,permutations,accumulate, product # (string,3) 3回

#from collections import deque

from collections import deque,defaultdict,Counter

import decimal

import re

import math

import bisect

import heapq

#

#

#

# pythonで無理なときは、pypyでやると正解するかも！！

#

#

# my_round_int = lambda x:np.round((x*2 + 1)//2)

# 四捨五入g

#

# インデックス系

# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);

# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);

#

#

import sys

sys.setrecursionlimit(10000000)

mod = 10**9 + 7

#mod = 9982443453

#mod = 998244353

from sys import stdin

readline = stdin.readline

def readInts():

  return list(map(int,readline().split()))

def readTuples():

    return tuple(map(int,readline().split()))

def I():

  return int(readline())

n = I()

L = readInts()

L = sorted(L)

# 1,2番目を特定する

ans = 0

for i in range(n-2):

    for j in range(i+1,n-1):

        a = L[i]

        b = L[j]

        c = bisect.bisect_left(L, a + b)

        ans += c - (j+1)

print(ans)

n = int(eval(input()))
L = sorted(list(map(int, input().split())))
import bisect

ans = 0
# print(L)
for a in range(n - 2):
    for b in range(a + 1, n - 1):
        p = bisect.bisect_left(L, L[a] + L[b])
        # print(bisect.bisect_left(L,L[a]+L[b]),"-",L[a] + L[b])
        ans += p - (b + 1)
print(ans)

# from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations, permutations, accumulate, product  # (string,3) 3回

# from collections import deque
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import bisect
import heapq

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys

sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
# mod = 998244353
from sys import stdin

readline = stdin.readline


def readInts():
    return list(map(int, readline().split()))


def readTuples():
    return tuple(map(int, readline().split()))


def I():
    return int(readline())


n = I()
L = readInts()
L = sorted(L)
# 1,2番目を特定する
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        a = L[i]
        b = L[j]
        c = bisect.bisect_left(L, a + b)
        ans += c - (j + 1)
print(ans)

-n = int(eval(input())) -L = sorted(list(map(int, input().split()))) +# from statistics import median +# import collections +# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] +from fractions import gcd +from itertools import combinations, permutations, accumulate, product  # (string,3) 3回 + +# from collections import deque +from collections import deque, defaultdict, Counter +import decimal +import re +import math +import heapq +# +# +# +# pythonで無理なときは、pypyでやると正解するかも！！ +# +# +# my_round_int = lambda x:np.round((x*2 + 1)//2) +# 四捨五入g +# +# インデックス系 +# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2); +# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2); +# +# +import sys + +sys.setrecursionlimit(10000000) +mod = 10**9 + 7 +# mod = 9982443453 +# mod = 998244353 +from sys import stdin + +readline = stdin.readline + + +def readInts(): +    return list(map(int, readline().split())) + + +def readTuples(): +    return tuple(map(int, readline().split())) + + +def I(): +    return int(readline()) + + +n = I() +L = readInts() +L = sorted(L) +# 1,2番目を特定する -# print(L) -for a in range(n - 2): -    for b in range(a + 1, n - 1): -        p = bisect.bisect_left(L, L[a] + L[b]) -        # print(bisect.bisect_left(L,L[a]+L[b]),"-",L[a] + L[b]) -        ans += p - (b + 1) +for i in range(n - 2): +    for j in range(i + 1, n - 1): +        a = L[i] +        b = L[j] +        c = bisect.bisect_left(L, a + b) +        ans += c - (j + 1)