CodeEff/ECCO huggingface dataset:
# Original solution
from bisect import bisect_left

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

num_triangles = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(a=L, x=L[i]+L[j], lo=j+1)
        num_triangles += idx-j-1
print(num_triangles)


# Optimized solution
from bisect import bisect_left

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

num_triangles = 0
for i in range(N-2): 
    for j in range(i+1, N-1):
        idx = bisect_left(L, L[i]+L[j], j+1)
        num_triangles += idx-j-1
print(num_triangles)
# Original solution
from collections import deque
from copy import copy
import bisect
 
n = int(eval(input()))
order = sorted(list(map(int, input().split())))
l = deque(order)
ans = 0
 
for _ in range(len(l)-2):
    first = l.pop()
    m = copy(l)
    for _ in range(len(m)-1):
        second = m.pop()
        fix = first-second
        ans += len(m)-bisect.bisect_right(list(m), fix)
 
print(ans)

# Optimized solution
from bisect import bisect_right

n = int(eval(input()))
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(list(range(2, n))):
    for j in reversed(list(range(1, i))):
        ans += j - bisect_right(order[0:j], order[i]-order[j])

print(ans)
# Original solution
from bisect import bisect_right

n = int(eval(input()))
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(list(range(2, n))):
    for j in reversed(list(range(1, i))):
        ans += j - bisect_right(order[0:j], order[i]-order[j])

print(ans)

# Optimized solution
from bisect import bisect_right

n = int(eval(input()))
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(list(range(2, n))):
    for j in reversed(list(range(1, i))):
        fix = bisect_right(order, order[i]-order[j])
        if j > fix:
            ans += j - fix

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

N, *X = list(map(int, open(0).read().split()))

X.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k1 = bisect_right(X, X[j] - X[i])
        k2 = bisect_left(X, X[i] + X[j])
        k1 = max(k1, j + 1)
        ans += max(0, k2 - k1)

print(ans)


# Optimized solution

from bisect import bisect_left

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

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

print(ans)
# Original solution
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

"""
nC3
|b - c| < a < |b + c|

nC2
b_i, c_iを除くiの中で|b-c|< a <b+cを満たすaの数をタス
"""

N = int(eval(input()))
L = LI()
L.sort()

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




# Optimized solution
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

"""
nC3
|b - c| < a < |b + c|

nC2
b_i, c_iを除くiの中で|b-c|< a <b+cを満たすaの数をタス
"""

N = int(eval(input()))
L = LI()
L.sort()

ans = 0
for i in range(N - 1, -1, -1):
    for j in range(i - 1, -1, -1):
        ans += j - bisect.bisect_right(L[:j], L[i] - L[j])
print(ans)
# Original solution
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort(reverse=True)

ans = 0
for i in range(N):
  j = N-2
  temp = 0
  while j > i:
    if temp > 0:
      k = temp
    else:
      k = N - 1
    while k > j:
      if L[i]-L[j]-L[k] < 0:
        ans += k-j
        temp = k
        break
      k -=1
    j -= 1
  
print(ans)


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

ck = [0]*(N-2)
ans = 0
for i in range(N-2):
  j = i + 1
  k = N - 1
  while j < k:
    if L[i]-L[j]-L[k] < 0:
      ans += k-j
      j += 1 
    else:
      k -=1
  
print(ans)
# Original solution
from bisect import bisect
from bisect import bisect_right
from bisect import bisect_left
from bisect import insort
from bisect import insort_right
from bisect import insort_left

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

cnt = 0
for i in range(N):
  for j in range(i+1, N):
    s = L[i] + L[j]
    x = bisect_left(L, s)
    #print((L[i], L[j]), s, x)
    cnt += max(x - j - 1, 0)
print(cnt)

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

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

count = 0
for l in list(itertools.combinations(L, 3)):
    if l[0] < l[1] + l[2] and l[1] < l[0] + l[2] and l[2] < l[0] + l[1]:
        count += 1

print(count)

# Optimized solution
import itertools

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

L = sorted(L)

count = 0

for i in range(N - 1):
    for j in range(i + 1, N - 1):
        x, y = L[i], L[j]
        top = N
        bottom = j + 1
        tmp = (top + bottom) // 2
        
        while(top - bottom > 1):
            if L[tmp] >= x + y:
                top = tmp
                tmp = (top + bottom) // 2
            elif L[tmp] < x + y:
                bottom = tmp
                tmp = (top + bottom) // 2
        if bottom - j == 1:
            if L[bottom] < x + y:
                count += 1
        else:
            count += (bottom - j)

print(count)
# Original solution
import bisect
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):
    # ans+=bisect.bisect_left(L,L[i]+L[j])-j-1
    ans+=bisect.bisect_left(L,L[i]+L[j],j)-j-1
print(ans)

# Optimized solution
import bisect
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):
    ans+=bisect.bisect_left(L,L[i]+L[j])-j-1 # Code 1 
    # ans+=bisect.bisect_left(L,L[i]+L[j],j)-j-1 # Code 2 
print(ans)
# Original solution
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    l.sort()
    res = 0
    for i in range(n):
        for j in range(i+1, n):
            k = bisect.bisect_left(l, l[i]+l[j])
            res += max(k-(j+1), 0)
    print(res)
    return 0

if __name__ == "__main__":
    solve()

# Optimized solution
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    l.sort()
    res = 0
    for i in range(n):
        k = i
        for j in range(i+1, n):
            while(k < n and l[k] < l[i]+l[j]):
                k += 1
            res += k - (j+1)
    print(res)
    return 0

if __name__ == "__main__":
    solve()
# Original solution
import sys
input = sys.stdin.readline

N = int(eval(input()))
L = [int(i) for i in input().split()]
total = 0

L = sorted(L, reverse=True)

for i in range(N-2):
    if L[i+1] + L[i+2] <= L[i]:
        continue
    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]:
                total +=1
            else:
                break

print(total)


# Optimized solution
import sys
input = sys.stdin.readline

N = int(eval(input()))
L = [int(i) for i in input().split()]
total = 0

L = sorted(L)

for i in range(N-2):
    k = i + 2
    for j in range(i+1, N):
        while k < N and L[i] + L[j] > L[k]:
            k+=1
        if k > j:
            total += k-j-1

print(total)
# Original solution
n = int(eval(input()))
ln = list(map(int, input().split()))

ln.sort()

def binary_search(x, r):
    left = r + 1
    right = n-1
    while left < right:
        mid = (left + right) // 2
        if ln[mid] == x:
            return mid
        elif ln[mid] > x:
            right = mid - 1
        else:
            left = mid + 1
    mid = (left + right) // 2
    if ln[mid] > x:
        return mid - 1
    else:
        return mid


ans = 0
for a in range(n-2):
    for b  in range(a+1, n-1):
        cmin = ln[b] - ln[a] + 1
        cmax = ln[b] + ln[a] - 1
        ans += max(0, binary_search(cmax, b) - b)

print(ans)

# Optimized solution
n = int(eval(input()))
ln = list(map(int, input().split()))

ln.sort()

def binary_search(x, r):
    left = r + 1
    right = n - 1
    while left <= right:
        mid = (left + right) // 2
        if ln[mid] >= x:
            right = mid - 1
        else:
            left = mid + 1
    if ln[mid] >= x:
        return mid - 1
    else:
        return mid


ans = 0
for a in range(n-2):
    for b  in range(a+1, n-1):
        cmax = ln[b] + ln[a]
        ans += max(0, binary_search(cmax, b) - b)

print(ans)
# Original solution
#!/usr/bin/env python3
import sys
from bisect import bisect_left

def main():
    N = int(eval(input()))
    L = sorted(list(map(int, input().split())))
    ans = 0

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

if __name__ == '__main__':
    main()


# Optimized solution
from bisect import bisect_right

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):
        b = L[i]
        c = L[j]
        M = L[i+1:j]
        ans += bisect_right(M, b + c - 1) - bisect_right(M, c - b)
print(ans)
# Original solution
from bisect import bisect_left, bisect_right
n = int(eval(input()))
ls = sorted(list(map(int, input().split())))
total = 0
for i in range(n):
    for j in range(i+1, n):
        b, c = ls[i], ls[j]
        lower = abs(b-c) + 0.5
        upper = b+c - 0.5
        ii = bisect_left(ls, lower)
        jj = bisect_left(ls, upper)
        cnt = jj - ii
        if i in range(ii, jj):
            cnt -= 1
        if j in range(ii, jj):
            cnt -= 1
        total += cnt
total //= 3

print(total)


# Optimized solution
from bisect import bisect_left, bisect_right
n = int(eval(input()))
ls = sorted(list(map(int, input().split())))
total = 0
for i in range(n):
    for j in range(i+1, n):
        b, c = ls[i], ls[j]
        lower = abs(b-c) + 0.5
        upper = b+c - 0.5
        ii = bisect_left(ls, lower)
        jj = bisect_left(ls, upper)
        cnt = jj - ii
        if ii <= i < jj:
            cnt -= 1
        if ii <= j < jj:
            cnt -= 1
        total += cnt
total //= 3

print(total)
# Original solution
import sys
input = sys.stdin.readline
import collections
import bisect

def main():
    n = int(eval(input()))
    l = input_list()
    l.sort()
    ans = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            ind = bisect.bisect_left(l, l[i]+l[j])
            num = ind - 1 - j
            ans += num
    print(ans)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


# Optimized solution
import sys
input = sys.stdin.readline
import bisect


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n = int(eval(input()))
    l = sorted(input_list())
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            ans += bisect.bisect_left(l, l[a]+l[b]) - (b+1)
    print(ans)

def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()
# Original solution
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left

def solve():
    n = int(eval(input()))
    l = [int(x) for x in input().split()]
    l.sort()
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            r = bisect_left(l, l[i] + l[j])
            if r > j:
                ans += r - j - 1
    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""


# Optimized solution
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left

def solve():
    n = int(eval(input()))
    l = [int(x) for x in input().split()]
    l.sort()
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            r = bisect_left(l, l[i] + l[j])
            # if r > j:
            ans += r - j - 1
    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""
# Original 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):
    small = bisect.bisect_left(L, L[j]-L[i])
    large = bisect.bisect_left(L, L[j]+L[i])
    
    #print(i,j,L[i],L[j],"  ",L[j]-L[i],L[j]+L[i],small,large)
    ans += max(large-j-1,0)    
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):
    #small = bisect.bisect_left(L, L[j]-L[i])
    large = bisect.bisect_left(L, L[j]+L[i])    
    #print(i,j,L[i],L[j],"  ",L[j]-L[i],L[j]+L[i],small,large)
    ans += max(large-j-1,0)    

print(ans)
# Original solution
eval(input())
a = input().split(' ')
b = []
for i in a:
    b.append(int(i))
b.sort()
b.reverse()
out = 0
for i in range(len(b) - 2):
    l = i + 1
    r = len(b) - 1
    while l < r:
        if b[i] < b[l] + b[r]:
            out += r - l
            l += 1
        else:
            r -= 1

print(out)


# Optimized solution
n = int(eval(input()))
sticks = list (map (int, input().strip().split()))
sticks.sort()
ans = 0
for a_idx in range(n - 1, 0, -1):
    b_idx = a_idx - 1
    c_idx = 0
    while c_idx < b_idx:
        if sticks[a_idx] < sticks[b_idx] + sticks[c_idx]:
            ans += b_idx - c_idx
            b_idx -= 1
        else:
            c_idx += 1
print(ans)
# Original solution
import sys
input = sys.stdin.readline
import itertools
import bisect

def main():
    N = int(eval(input()))
    L = [int(x) for x in input().split()]
    ans = 0
    L_sorted = sorted(L)
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            a = L_sorted[i]
            b = L_sorted[j]
            l = bisect.bisect_left(L_sorted[j:], max(a - b, b - a))
            r = bisect.bisect_left(L_sorted[j:], a + b)
            ans += r - l - 1

    print(ans)



    

if __name__ == '__main__':
    main()



# Optimized solution
import sys
input = sys.stdin.readline
import itertools
import bisect

def main():
    N = int(eval(input()))
    L = [int(x) for x in input().split()]
    ans = 0
    L_sorted = sorted(L)
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            a = L_sorted[i]
            b = L_sorted[j]
            l = bisect.bisect_left(L_sorted, max(a - b, b - a), lo=j + 1)
            r = bisect.bisect_left(L_sorted, a + b, lo=j + 1)
            ans += r - l

    print(ans)



    

if __name__ == '__main__':
    main()
# Original solution
import sys
input = sys.stdin.readline
import itertools
import bisect

def main():
    N = int(eval(input()))
    L = [int(x) for x in input().split()]
    ans = 0
    L_sorted = sorted(L)
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            a = L_sorted[i]
            b = L_sorted[j]
            l = bisect.bisect_left(L_sorted, max(a - b, b - a), lo=j + 1)
            r = bisect.bisect_left(L_sorted, a + b, lo=j + 1)
            ans += r - l

    print(ans)



    

if __name__ == '__main__':
    main()



# Optimized solution
import sys
input = sys.stdin.readline
import itertools
import bisect

def main():
    N = int(eval(input()))
    L = [int(x) for x in input().split()]
    ans = 0
    L_sorted = sorted(L)
    for i in range(N - 2):
        a = L_sorted[i]
        for j in range(i + 1, N - 1):
            b = L_sorted[j]
            r = bisect.bisect_left(L_sorted, a + b, lo=j + 1)
            ans += r - j - 1

    print(ans)



    

if __name__ == '__main__':
    main()
# Original solution
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(eval(input()))
def MI() : return list(map(int, input().split()))
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(eval(input())) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in list(currentframe().f_back.f_locals.items())}; print((', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args)))

N = I()
L = LI()

L.sort()

ans = 0
for i, l in enumerate(L):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if l + L[j] <= L[k]:
                break
            ans += 1

print(ans)

# Optimized solution
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
L = LI()

L.sort()

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

        ans += max(0, c - (j+1))

print(ans)
# Original solution
from sys import stdout
import bisect
printn = lambda x: stdout.write(x)
inn = lambda : int(eval(input()))
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      list(map(int, input().split())) 
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
l = inl()
acc = 0
l.sort()
for i in range(n-2):
  a = l[i]
  for j in range(i+1,n-1):
    b = l[j]
    e = bisect.bisect_left(l,a+b)
    ddprint("a {} b {} i {} j {} e {}".format(a,b,i,j,e))
    acc += e-j-1
print(acc)


# Optimized solution
from sys import stdout
import bisect
printn = lambda x: stdout.write(x)
inn = lambda : int(eval(input()))
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      list(map(int, input().split())) 
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
l = inl()
acc = 0
l.sort()
for i in range(n-2):
  a = l[i]
  for j in range(i+1,n-1):
    b = l[j]
    e = bisect.bisect_left(l[j+1:],a+b)
    #ddprint("a {} b {} i {} j {} e {}".format(a,b,i,j,e))
    acc += e  #-j-1
print(acc)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
ans = 0
for r in range(n-1,-1,-1):
  m = r
  for l in range(n):
    if l == m and m + 1 < r:
      m += 1
    while True:
      if a[l] + a[m-1] > a[r] and l < m-1:
        m -= 1
      else:
        break
    if l < m < r:
      ans += r - m
      #print(l,m,r)
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
ans = 0
for r in range(n-1,-1,-1):
  m = r
  for l in range(n):
    if l == m and m + 1 < r:
      m += 1
    else:
      while True:
        if a[l] + a[m-1] > a[r] and l < m-1:
          m -= 1
        else:
          break
    if l < m < r:
      ans += r - m
      #print(l,m,r)
print(ans)
# Original solution
import itertools
n = int(eval(input()))
l = list(map(int,input().split()))
c = [i for i in itertools.combinations(l,3) if i[0]<i[1]+i[2] and i[1]<i[2]+i[0] and i[2]<i[0]+i[1]]
print((len(c)))

# Optimized solution
import bisect
n = int(eval(input()))
l = list(map(int,input().split()))
l.sort()
ans = 0
for b in range(n):
  for a in range(b):
    ans += bisect.bisect_left(l,l[a]+l[b])-(b+1)
print(ans)
# Original solution
import itertools
import bisect
n=int(eval(input()))
count = 0
a=sorted(list(map(int, input().split(" "))))
for i in range(2,n):
  for j, k in itertools.combinations(a[:i], 2):
    if j + k > a[i]:
      count += 1
print(count)

# Optimized solution
n = int(eval(input()))
import bisect
a = sorted(list(map(int, input().split(" "))))
ans = 0
for i in range(1, n-1):
  b = a[:i]
  c = a[i + 1:]
  #print(b, c)
  for j in b:
    ans += bisect.bisect(c, a[i]+j-0.1)
    #print(bisect.bisect(c, a[i]+j-0.1))
print(ans)
# Original solution
import sys
N = int(eval(input()))
L = list(map(int, input().split()))

from itertools import permutations, combinations,combinations_with_replacement,product
nCr = list(combinations(list(range(N)), 3))

ret = 0
for i in nCr:
  if L[i[0]]<L[i[1]]+L[i[2]] and L[i[1]]<L[i[2]]+L[i[0]] and L[i[2]]<L[i[0]]+L[i[1]]:
    ret +=1
print(ret)

# Optimized solution
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ret = 0
for i in range(0, N-2):
    for j in range(i+1, N-1):
        ret += len([k for k in L[j+1:] if L[i]+L[j]>k])
print(ret)
# Original solution
import bisect
def main():
 
    N = int(eval(input()))
    L = list(map(int, input().split()))
    L.sort()
 
    # print(L)
    ab =[L[0]+L[1]]
    ans = 0
    for i in range(2, N):
        c = L[i]
        j = bisect.bisect_right(ab, c)
        # print(j)
        # print(ab)
        ans += len(ab) - j
        for k in range(i):
            bisect.insort_left(ab, c+L[k])
        # print(ab)
    return ans
 
if __name__ == '__main__':
    print((main()))

# Optimized solution
import bisect
def main():
 
    N = int(eval(input()))
    L = list(map(int, input().split()))
    L.sort()
 
    # print(L)
    ans = 0
    for i in range(N-2):
        for j in range(i+2, N):
            a = L[i]
            c = L[j]
            k = bisect.bisect_left(L, c-a+1)
            if k <= i:
                ans += j-i-1
            else:
                ans += j-k
    return ans
 
if __name__ == '__main__':
    print((main()))