import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ls = list(mapint())
Ls.sort()

from bisect import bisect_left
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(Ls, Ls[i]+Ls[j])
        ans += idx-1-j

print(ans) import sys sys def input(): return sys.stdin.readline().strip() input def mapint(): return map(int, input().split()) mapint sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 N = int(input()) N int(input()) int input() input Ls = list(mapint()) Ls list(mapint()) list mapint() mapint Ls.sort() Ls.sort Ls sort from bisect import bisect_left ans = 0 ans 0 for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(Ls, Ls[i]+Ls[j])
        ans += idx-1-j i range(N-2) range N-2 N 2 for j in range(i+1, N-1):
        idx = bisect_left(Ls, Ls[i]+Ls[j])
        ans += idx-1-j j range(i+1, N-1) range i+1 i 1 N-1 N 1 idx = bisect_left(Ls, Ls[i]+Ls[j]) idx bisect_left(Ls, Ls[i]+Ls[j]) bisect_left Ls Ls[i]+Ls[j] Ls[i] Ls i Ls[j] Ls j ans += idx-1-j ans idx-1-j idx-1 idx 1 j print(ans) print ans ans += idx-1-j idx-1-j ans N = int(input()) int(input()) N def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input def mapint(): return map(int, input().split()) def mapint(): return map(int, input().split()) mapint Ls = list(mapint()) list(mapint()) Ls idx = bisect_left(Ls, Ls[i]+Ls[j]) bisect_left(Ls, Ls[i]+Ls[j]) idx ans = 0 0 ans
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ls = list(mapint())
Ls.sort()

from bisect import bisect_left
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(Ls, Ls[i]+Ls[j])
        ans += idx-1-j

print(ans)