#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) from fractions import gcd from itertools import combinations,permutations,accumulate, product from collections import deque,defaultdict,Counter import decimal decimal import re re import math math import bisect bisect import heapq heapq import sys sys sys.setrecursionlimit(10000000) sys.setrecursionlimit sys setrecursionlimit 10000000 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 from sys import stdin readline = stdin.readline readline stdin.readline stdin readline def readInts():
  return list(map(int,readline().split())) readInts return list(map(int,readline().split())) list(map(int,readline().split())) list map(int,readline().split()) map int readline().split() ().split () readline split def readTuples():
    return tuple(map(int,readline().split())) readTuples return tuple(map(int,readline().split())) tuple(map(int,readline().split())) tuple map(int,readline().split()) map int readline().split() ().split () readline split def I():
  return int(readline()) I return int(readline()) int(readline()) int readline() readline n = I() n I() I L = readInts() L readInts() readInts L = sorted(L) L sorted(L) sorted L ans = 0 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) i range(n-2) range n-2 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) j range(i+1,n-1) range i+1 i 1 n-1 n 1 a = L[i] a L[i] L i b = L[j] b L[j] L j c = bisect.bisect_left(L, a + b) c bisect.bisect_left(L, a + b) bisect.bisect_left bisect bisect_left L a + b a b ans += c - (j+1) ans c - (j+1) c j+1 j 1 print(ans) print ans L = readInts() readInts() L L = sorted(L) sorted(L) L mod = 10**9 + 7 10**9 + 7 mod a = L[i] L[i] a def I():
  return int(readline()) def I():
  return int(readline()) I b = L[j] L[j] b def readTuples():
    return tuple(map(int,readline().split())) def readTuples():
    return tuple(map(int,readline().split())) readTuples def readInts():
  return list(map(int,readline().split())) def readInts():
  return list(map(int,readline().split())) readInts ans = 0 0 ans c = bisect.bisect_left(L, a + b) bisect.bisect_left(L, a + b) c ans += c - (j+1) c - (j+1) ans readline = stdin.readline stdin.readline readline n = I() I() n
#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)
