from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
l = sorted(LIST())

ans = 0
for i in range(n-2):
    right = i + 2
    for j in range(i+1, n-1):
        left = j + 1
        while right < n-1 and l[right] < l[i] + l[j]:
            right += 1
        ans += right - left
        if l[right] < l[i] + l[j]:
            ans += 1
print(ans) from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator import itemgetter from heapq import heappop,heappush from copy import deepcopy from time import time import string string import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 def input() : return sys.stdin.readline().strip() input def INT()   : return int(input()) INT def MAP()   : return map(int,input().split()) MAP def LIST()  : return list(MAP()) LIST n = INT() n INT() INT l = sorted(LIST()) l sorted(LIST()) sorted LIST() LIST ans = 0 ans 0 for i in range(n-2):
    right = i + 2
    for j in range(i+1, n-1):
        left = j + 1
        while right < n-1 and l[right] < l[i] + l[j]:
            right += 1
        ans += right - left
        if l[right] < l[i] + l[j]:
            ans += 1 i range(n-2) range n-2 n 2 right = i + 2 right i + 2 i 2 for j in range(i+1, n-1):
        left = j + 1
        while right < n-1 and l[right] < l[i] + l[j]:
            right += 1
        ans += right - left
        if l[right] < l[i] + l[j]:
            ans += 1 j range(i+1, n-1) range i+1 i 1 n-1 n 1 left = j + 1 left j + 1 j 1 while right < n-1 and l[right] < l[i] + l[j]:
            right += 1
         right < n-1 and l[right] < l[i] + l[j] right < n-1 right n-1 n 1 l[right] < l[i] + l[j] l[right] l right l[i] + l[j] l[i] l i l[j] l j right += 1 right 1 ans += right - left ans right - left right left if l[right] < l[i] + l[j]:
            ans += 1 l[right] < l[i] + l[j] l[right] l right l[i] + l[j] l[i] l i l[j] l j ans += 1 ans 1 print(ans) print ans ans = 0 0 ans l = sorted(LIST()) sorted(LIST()) l left = j + 1 j + 1 left ans += 1 1 ans def MAP()   : return map(int,input().split()) def MAP()   : return map(int,input().split()) MAP right = i + 2 i + 2 right def INT()   : return int(input()) def INT()   : return int(input()) INT def input() : return sys.stdin.readline().strip() def input() : return sys.stdin.readline().strip() input n = INT() INT() n def LIST()  : return list(MAP()) def LIST()  : return list(MAP()) LIST right += 1 1 right ans += right - left right - left ans
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
l = sorted(LIST())

ans = 0
for i in range(n-2):
    right = i + 2
    for j in range(i+1, n-1):
        left = j + 1
        while right < n-1 and l[right] < l[i] + l[j]:
            right += 1
        ans += right - left
        if l[right] < l[i] + l[j]:
            ans += 1
print(ans)