CodeEff/ECCO huggingface dataset:
# Original solution
#!/usr/bin/env python3
import sys
import itertools
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
from collections import Counter


def solve(N: int, L: "List[int]"):
    ans = 0
    L.sort()

    for x in range(N):
        for y in range(x+1,N):
            # if x==y : continue
            zs = bisect_right(L, max(L[x],L[y]))
            ze = bisect_left(L, L[x]+L[y])            
            cnt = 0
            if(zs <= x <= ze):
                cnt += 1
            if(zs <= y <= ze):
                cnt += 1
            ans += ((ze-zs)-cnt)

    print(ans)

    return
 


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys

from bisect import bisect_left, bisect_right



def solve(N: int, L: "List[int]"):
    ans = 0
    L.sort()

    for x in range(N):
        for y in range(x+1,N):
            ze = bisect_left(L, L[x]+L[y])            
            ans += (ze-y-1)
            
    print(ans)

    return
 


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()
# Original solution
#!/usr/bin/env python3
import sys


def solve(N: int, L: "List[int]"):
    L.sort()

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            from bisect import bisect_left, bisect_right
            k = bisect_left(L, L[i]+L[j])
            ans += (k-(j+1))

    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
from bisect import bisect_left, bisect_right

def solve(N: int, L: "List[int]"):
    L.sort()

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            k = bisect_left(L, L[i]+L[j])
            ans += (k-j-1)

    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()
# Original solution
N=int(eval(input()))
l=list(map(int,input().split()))
L=list(l)
a=0
for i in range(N):
 for j in range(N-i-1):
  for k in range(N-j-i-2):
    if L[i]<L[i+j+1]+L[k+i+j+2] and L[i]>abs(L[i+j+1]-L[k+i+j+2]):
     a+=1
print(a)

# Optimized solution
import sys
input = sys.stdin.readline
N=int(eval(input()))
L=list(map(int,input().split()))
L.sort()
ans=0
for i in range(N-2):
 mid =i+1
 l=0
 r=i+2
 while r<N:
  if L[r]-L[l]<L[mid]:
   ans+=(mid-l)
   r+=1
  else:
   if l==mid-1:
    r+=1
   else:
    l+=1
print(ans)
# Original solution
N=int(eval(input()))
*L,=list(map(int,input().split()))

L.sort()
from bisect import*
i=0
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        ans+=bisect_left(L[j:],L[i]+L[j])-1

print(ans)

# Optimized solution
N=int(eval(input()))
*L,=list(map(int,input().split()))

L.sort()
from bisect import*
i=0
ans=0
while i<N:
    j=i+1
    while j<N:
        ans+=bisect_left(L,L[i]+L[j])-j-1
        j+=1
    i+=1

print(ans)
# Original solution
from bisect import bisect_left, bisect_right

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()

ans = 0
for i, A in enumerate(L):
    for j, B in enumerate(L):
        if i == j:
            continue
        left = bisect_right(L, abs(A - B))
        right = bisect_left(L, A + B)

        ans += right - left

        if left <= i < right:
            ans -= 1
        if left <= j < right:
            ans -= 1

print((ans // 6))

# Optimized solution
from bisect import bisect_left

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()

ans = 0
for i, A in enumerate(L):
    for j, B in enumerate(L[i + 1:], start=i + 1):
        right = bisect_left(L, A + B)
        ans += right - j - 1

print(ans)
# Original solution
import math
import sys
from collections import Counter
import bisect
readline = sys.stdin.readline


def main():
    cnt = 0
    n = int(readline().rstrip())
    L = sorted(list(map(int, readline().rstrip().split())))
    for a in range(0, n - 2):
        for b in range(a + 1, n - 1):
            k = L[a] + L[b]
            l = sorted(L[b + 1: len(L)])
            index = bisect.bisect_left(l, k)
            cnt += index
    print(cnt)


if __name__ == '__main__':
    main()


# Optimized solution
import math
import sys
from collections import Counter
import bisect
readline = sys.stdin.readline


def main():
    cnt = 0
    n = int(readline().rstrip())
    L = sorted(list(map(int, readline().rstrip().split())))
    for a in range(0, n - 2):
        for b in range(a + 1, n - 1):
            k = L[a] + L[b]
            index = bisect.bisect_left(L, k)
            cnt += index - b - 1
    print(cnt)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()

c=0
for i in range (N-2):
    for j in range (i+1,N-1):
        for k in range (j+1,N):
            if L[i]+L[j] > L[k]: #and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]:
                c += 1
            else:
                break

print(c)

# Optimized solution
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()
c = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        zum = L[i]+L[j]
        start = j+1
        goal = N-1
        now = (start + goal)//2

        if zum > L[goal]:
            c += goal - j
        elif zum <= L[start]:
            c += 0
        else:
            while not L[now] < zum <= L[now+1]:
                now = (start + goal)//2
                if zum > L[now]:
                    start = now
                else:
                    goal = now
            c += now - j

print(c)
# Original solution
N = int(eval(input()))
L = list(map(int, input().split()))

L.sort()
count = 0

for i in reversed(list(range(N))):
  for j in reversed(list(range(i))):
    for k in range(j):
      if L[j] + L[k] > L[i]:
        count += j - k
        break
        
print(count)

# Optimized solution
N = int(eval(input()))
L = list(map(int, input().split()))
 
L.sort()
count = 0
 
for i in reversed(list(range(N))):
  kmin = 0
  for j in reversed(list(range(i))):
    for k in range(kmin,j):
      if L[j] + L[k] > L[i]:
        count += j - k
        kmin = k
        break
        
print(count)
# Original solution
n = int(eval(input()))
arr = sorted(list(map(int,input().split())))

count = 0

for a in range(n-2):
    for b in range(a+1,n-1):
        for c in range(b+1,n):
            if arr[a]<arr[b]+arr[c] and arr[b]<arr[c]+arr[a] and arr[c]<arr[a]+arr[b]:
                count +=1
            else:
                break

print(count)

# Optimized solution

n = int(eval(input()))
arr = list(map(int,input().split()))
arr.sort()

count = 0

for a in range(n-2):
    k = a+2
    for j in range(a+1,n):
        while (k < n and arr[a] + arr[j] > arr[k]):
            k+=1
        
        if k>j:
            count += k-j-1
        
print(count)
# Original solution
import itertools
def resolve():
    n = int(eval(input()))
    l = tuple(map(int,input().split()))
    cnt = 0
    for i in itertools.combinations(l,3):
        a,b,c = i
        if a<b+c and b<c+a and c<a+b:
            cnt += 1
    print(cnt)
resolve()

# Optimized solution
import bisect
def resolve():
    n = int(eval(input()))
    l = sorted(list(map(int,input().split())))
    ans = 0
    for a in range(n):
        for b in range(a+1,n):
            c = bisect.bisect_left(l,l[a]+l[b])
            if c > b:
                ans += c-b-1
            else:
                pass
    print(ans)
resolve()
# Original solution
import sys
import math


# input = sys.stdin.readline

def binary_search(arr, key,j):
    ok = j
    ng = len(arr)

    while abs(ok - ng) > 1:
        mid = int((ok + ng) / 2)

        if arr[mid] < key:
            ok = mid
        else:
            ng = mid

    return ok


def main():
    N = int(eval(input()))
    L = sorted(list(map(int, input().split())))
    ans =0
    for i in range(N-2):
        for j in range(i+1,N-1):
            ok = binary_search(L,L[i]+L[j],j)
            ans += ok-j
    print(ans)
if __name__ == "__main__":
    main()


# Optimized solution
import sys
#import math


# input = sys.stdin.readline

def binary_search(arr, key,j):
    ok = j
    ng = len(arr)

    while abs(ok - ng) > 1:
        mid = int((ok + ng) / 2)

        if arr[mid] < key:
            ok = mid
        else:
            ng = mid

    return ok


def main():
    N = int(eval(input()))
    L = sorted(list(map(int, input().split())))
    ans =0
    for i in range(N-2):
        for j in range(i+1,N-1):
            ok = binary_search(L,L[i]+L[j],j)
            ans += ok-j
    print(ans)
if __name__ == "__main__":
    main()
# Original solution
from itertools import combinations as comb
n = int(eval(input()))
l = list(map(int,input().split()))
l.sort()
tri = set()
for a,b,c in comb(l,3):
  if a<b+c and b<c+a and c<a+b:
    tri.add((a,b,c))
print((len(tri)))

# Optimized solution
import bisect
n = int(eval(input()))
l = list(map(int,input().split()))
l.sort()
c = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    c += bisect.bisect_right(l,l[j]+l[i]-1) - bisect.bisect_left(l,l[j],j+1)
print(c)
# Original solution
import bisect
N = int(eval(input()))
L = sorted([int(x) for x in input().split()])
cnt = 0
#print(L)
for i in range(N-2):
    for j in range(i+1, N-1):
        #print(i, j)
        #print(bisect.bisect_left(L, L[i]+L[j]))
        cnt +=  bisect.bisect_left(L, L[i]+L[j]) - (j+1)
print(cnt)

# Optimized solution
import bisect
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        tmp = L[i]+L[j]
        point = bisect.bisect_left(L,tmp)
        ans += point - j - 1
print(ans)
# Original solution
n = int(eval(input()))
l = list(map(int, input().split(' ')))
l.sort()
counter = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        s = j + 1
        while s < n and l[i] + l[j] > l[s]:
            s += 1
        counter += s-j-1
print(counter)

# Optimized solution
n = int(eval(input()))
l = list(map(int, input().split(' ')))
l.sort()
counter = 0
for i in range(n):
    s = i + 2
    for j in range(i+1,n):        
        while (s < n and l[i] + l[j] > l[s]):
            s += 1
        counter += s-j-1
print(counter)
# Original solution
import bisect
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
res = 0
for i in range(N - 1, 1, - 1):
    for j in range(i - 1, 0, - 1):
        k = L[i] - L[j] + 1
        if k > L[j - 1]:
            break
        res += j - bisect.bisect_left(L, k)
print(res)

# Optimized solution
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
res = 0
for i in range(N - 1, 1, - 1):
    j = i - 1
    k = 0
    while j > k:
        while j > k and L[i] >= L[j] + L[k]:
            k += 1
        res += j - k
        j -= 1
print(res)
# Original solution
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
res = 0
for i in range(N - 1, 1, - 1):
    j = i - 1
    k = 0
    while j > k:
        while j > k and L[i] >= L[j] + L[k]:
            k += 1
        res += j - k
        j -= 1
print(res)

# Optimized solution
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
res = 0
for i in range(N - 1, 1, - 1):
    j = i - 1
    k = 0
    while j > k:
        if L[i] < L[j] + L[k]:
            res += j - k
            j -= 1
        else:
            k += 1
print(res)
# Original solution
n=int(eval(input()))
l=list(map(int,input().split()))
c=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i]<l[j]+l[k] and l[j]<l[i]+l[k] and l[k]<l[i]+l[j]:
        c+=1
print(c)

# Optimized solution
n=int(eval(input()))
l=list(map(int,input().split()))
c=0
dp=[]
l.sort()
for i in range(n-2):
  k=i+2
  for j in range(i+1,n-1):
    while k<n and (l[i]+l[j])>l[k]:
      k+=1
    c+=k-j-1
print(c)

'''

1 2 3 4

1 < 2+3
2 < 1+3
3 < 1+2

6 - 1 = 5
6 - 2 = 4
6 - 3 = 3

'''
# Original solution
from bisect import bisect_left

N=int(eval(input()))
L=list(map(int, input().split()))
L.sort()
ans=0
for i in range(N):
  for j in range(i+1, N):
    ans+=bisect_left(L[j+1:], L[i]+L[j])
print(ans)

# Optimized solution
import bisect

N=int(eval(input()))
L=list(map(int, input().split()))
L.sort()

ans=0
for i in range(N):
    a=L[i]
    for j in range(i+1, N):
        b=L[j]
        ans+=bisect.bisect_left(L, a+b)-(j+1)
print(ans)
# Original solution
import bisect

N=int(eval(input()))
L=list(map(int, input().split()))
L.sort()

ans=0
for i in range(N):
    a=L[i]
    for j in range(i+1, N):
        b=L[j]
        ans+=bisect.bisect_left(L, a+b)-(j+1)
print(ans)


# Optimized solution
import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    a = L[i]
    for j in range(i+1, N):
        b = L[j]
        ans += bisect.bisect_left(L, a+b)-j-1
print(ans)
# Original solution
import itertools
n = int(eval(input()))
l = list(map(int,input().split()))
cnt = 0

for x,y,z in itertools.combinations(l,3):
  lt = sorted([x,y,z])
  if lt[2] < lt[0] + lt[1]:
    cnt += 1
print(cnt)

# Optimized solution
import bisect
n = int(eval(input()))
l = sorted(list(map(int,input().split())))
cnt = 0

for i in range(n):
  for j in range(1+i,n):
    a,b = l[i],l[j]
    cnt += bisect.bisect_left(l,a+b)-(j+1)
    
print(cnt)
# Original solution
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
c=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if l[i]+l[j]>l[k]:
        c+=1
print(c)    

# Optimized solution
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort(reverse=True)
c=0
for i in range(n-2):
  for j in range(i+1,n-1):
    u=l[i]-l[j]
    if l[j+1]<=u:
      break
    ok=j+1
    ng=n
    while ng-ok>1:
      center=(ok+ng)//2
      if l[center]>u:
        ok=center
      else:
        ng=center
    c+=ng-j-1
print(c)
# Original solution
n = int(eval(input()))
l = input().split()

l = list(l)
for i in range(n):
	l[i] = int(l[i])
l.sort()
count = 0
#a<b+c, a>b-c, a>c-b
for a in range(n):
	for b in range(a+1,n):
		for c in range(b+1,n):
			if l[a]<l[b]+l[c]:
				if l[b]<l[c]+l[a]:
					if l[c]<l[a]+l[b]:
						count += 1
					else:
						break

print(count)

# Optimized solution
import bisect

n = int(eval(input()))
l = list(map(int,input().split()))
l.sort()

ans = 0

#a<b+c, a>b-c, a>c-b
for a in range(n-2):
	for b in range(a+1,n-1):
		index = bisect.bisect_left(l,l[a]+l[b])
		ans += index - (b+1)
print(ans)
# Original solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from bisect import bisect_left
    n=int(eval(input()))
    L=list(map(int,input().split()))
    L.sort()
    ans=0
    for i in range(1,n):
        for j in range(i+1,n):
            k=bisect_left(L,L[j]-L[i]+1)
            ans+=max(0,i-k)
    print(ans)
resolve()

# Optimized solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(eval(input()))
    L=list(map(int,input().split()))
    L.sort()
    ans=0
    for b in range(1,n-1):
        c=b+1
        for a in range(b):
            while(c<n and L[a]+L[b]>L[c]): c+=1
            ans+=c-b-1
    print(ans)
resolve()
# Original solution
# ソートしたやつの小さい方から2つを決めてもうひとつはにぶたん
# 3, 5としたときに残りの一つは5, 6, 7みたいになる
# このにぶたんなんか実装がめっっっちゃむずくない？サンプル1が通らんのだが

import bisect

n = int(eval(input()))
arr = sorted(list(map(int, input().split())))


def lower_bound(arr, x):
    l, r = 0, len(arr)
    while l < r:
        mid = (l + r) // 2
        if arr[mid] < x:
            l = mid + 1
        else:
            r = mid
    return l


ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        idx_l = lower_bound(arr, arr[i] + arr[j]) - 1
        # print(
        #     "arr[{}]+arr[{}]={}より小さくなるはじめてのインデックス {}".format(
        #         i, j, arr[i] + arr[j], idx_l
        #     )
        # )
        # print("idx_l = {}, arr[{}]={}".format(idx_l, idx_l, arr[idx_l]))
        # print("範囲 {}".format(arr[j + 1 : idx_l + 1]))
        ans += len(arr[j + 1 : idx_l + 1])
print(ans)


# Optimized solution
# ソートしたやつの小さい方から2つを決めてもうひとつはにぶたん
# 3, 5としたときに残りの一つは5, 6, 7みたいになる
# このにぶたんなんか実装がめっっっちゃむずくない？サンプル1が通らんのだが
# やったけどTLEなるな

import bisect

n = int(eval(input()))
arr = sorted(list(map(int, input().split())))


def lower_bound(arr, x):
    l, r = 0, len(arr)
    while l < r:
        mid = (l + r) // 2
        if arr[mid] < x:
            l = mid + 1
        else:
            r = mid
    return l


ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        idx_l = lower_bound(arr, arr[i] + arr[j]) - 1
        # print(
        #     "arr[{}]+arr[{}]={}より小さくなるはじめてのインデックス {}".format(
        #         i, j, arr[i] + arr[j], idx_l
        #     )
        # )
        # print("idx_l = {}, arr[{}]={}".format(idx_l, idx_l, arr[idx_l]))
        # print("範囲 {}".format(arr[j + 1 : idx_l + 1]))
        ans += len(arr[j + 1 : idx_l + 1])
print(ans)
# Original solution
import itertools
N = int(eval(input()))

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

listarray = itertools.combinations(L,3)
count = 0

for items in listarray:
  a = items[0]
  b = items[1]
  c = items[2]
  if a < b + c and b < c + a and c < a + b:
    count +=1

print(count)

# Optimized solution
from bisect import bisect_left

N = int(eval(input()))
L = list(map(int, input().split()))

L.sort()

ans = 0
for i in range(N - 2):
  a = L[i]
  for j in range(i + 1, N - 1):
    b = L[j]
    c = bisect_left(L, a + b)
    ans += c - j - 1

print(ans)
# Original solution
n = int(eval(input()))
li = list(map(int, input().split()))
li.sort(reverse=True)
count = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        right = n - 1
        rightFlag = 1
        while rightFlag == 1 and right - j >= 1:
            if li[i] - li[j] >= li[right]:
                right -= 1
            else:
                rightFlag = 0
        if rightFlag == 0:
            count += right - j

print(count)


# Optimized solution
n = int(eval(input()))
li = list(map(int, input().split()))
li.sort(reverse=True)
count = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        left = j
        right = n

        while right - left > 1:
            mid = (left + right)//2
            if li[i]-li[j] < li[mid]:
                left = mid
            else:
                right = mid
        count += left - j

print(count)
# Original solution
import bisect

# 入力
def read_data():
    N_ = int(eval(input()))
    L_ = list(map(int, input().split()))
    return N_, L_

#探索
def binarySearch(N :int, L):
    ans = 0
    L.sort()
    # a,b は固定する
    for a_index in range(N):
        for b_index in range(a_index + 1, N):
            sum_of_a_and_b = L[a_index] + L[b_index]
            # c の可動範囲の右端を求める
            c_right_index = bisect.bisect_left(L, sum_of_a_and_b)
            # c の可動範囲は[b_index + 1, c_right_index) 右端が)となっているので-1している
            ans += max(0, c_right_index - b_index - 1)
    print(ans)

N, L = read_data()
binarySearch(N, L)

# Optimized solution
import bisect

# 入力
def read_data():
    N_ = int(eval(input()))
    L_ = list(map(int, input().split()))
    return N_, L_

#探索
def binarySearch(N :int, L):
    ans = 0
    L.sort()
    # a,b は固定する
    for a_index in range(N):
        for b_index in range(a_index + 1, N):
            sum_of_a_and_b = L[a_index] + L[b_index]
            # c の可動範囲の右端を求める
            c_right_index = bisect.bisect_left(L, sum_of_a_and_b)
            # c の可動範囲は[b_index + 1, c_right_index)
            ans += max(0, c_right_index - b_index - 1)
    print(ans)

N, L = read_data()
binarySearch(N, L)
# Original solution
import bisect

# 入力
def read_data():
   N_ = int(eval(input()))
   L_ = list(map(int, input().split()))
   return N_, L_

# 探索
def Search(N, L):
   ans = 0
   L.sort()
   # a, b は固定する
   for a_index in range(N):
       for b_index in range(a_index + 1, N):
           sum_of_a_and_b = L[a_index] + L[b_index]
           # c の可動範囲の右端を求める
           c_right_index = bisect.bisect_left(L, sum_of_a_and_b)
           # c の可動範囲は[b_index + 1, c_right_index)
           ans += max(0, c_right_index - b_index - 1)
   print(ans)

N, L = read_data()
Search(N, L)

# Optimized solution
import bisect

# 入力
def read_data():
    N_ = int(eval(input()))
    L_ = list(map(int, input().split()))
    return N_, L_

# 探索
def Search(N, L):
    ans = 0
    L.sort()
   # a, b は固定する
    for a_index in range(N):
       for b_index in range(a_index + 1, N):
           sum_of_a_and_b = L[a_index] + L[b_index]
           # c の可動範囲の右端を求める
           c_right_id = bisect.bisect_left(L, sum_of_a_and_b)
           # c の可動範囲は[b_index + 1, c_right)
           ans += max(0, c_right_id - b_index - 1)
    print(ans)

N, L = read_data()
Search(N, L)
# Original solution
def compose():
    N = int( eval(input()) )
    t_list = list( map( int, input().split() ) )
    t_list.sort()
    t_list.reverse()
    counter = 0
    a = 0
    for i in t_list:
        a += 1
        b = a
        for j in t_list[a:]:
            b += 1
            new_list = [ k for k in t_list[b:] if k > i - j ]
            counter += len(new_list)
    return counter

def main():
    print((compose()))
    
main()

# Optimized solution
from bisect import bisect_left
N = int ( eval(input()) )
t_list = list ( map ( int, input().split() ) )
t_list.sort()
ans = 0

for i in range ( N - 2 ):
  a = t_list[i]
  for j in range ( i + 1, N - 1 ):
    b = t_list[j]
    c = bisect_left ( t_list , a + b)
    ans += c - j - 1
    
print(ans)
# Original solution
n = int(eval(input()))
l = list(map(int,input().split()))

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

print(ans)

# Optimized solution
import bisect

n = int(eval(input()))
l = list(map(int,input().split()))
l.sort()

ans = 0
for i in range(n-2) :
  for j in range(i+1,n-1) :
    index = bisect.bisect_left(l,l[i]+l[j])
    ans += index-1-j

print(ans)