import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    import bisect
    n = i_input()
    l = sorted(i_list())
    ans = 0
    for a in range(n-2):
        for b in range(a+1,n-1):
            ans += bisect.bisect(l, l[a]+l[b]-1) -b-1
    print(ans)

if __name__=="__main__":
    main() import math math from math import gcd,pi,sqrt INF = float("inf") INF float("inf") float "inf" import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 import itertools itertools from collections import Counter,deque def i_input(): return int(input()) i_input def i_map(): return map(int, input().split()) i_map def i_list(): return list(i_map()) i_list i_input() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) i_input() i_input def i_row(N): return [i_input() for _ in range(N)] i_row N N i_list() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) i_list() i_list def i_row_list(N): return [i_list() for _ in range(N)] i_row_list N N def s_input(): return input() s_input def s_map(): return input().split() s_map def s_list(): return list(s_map()) s_list s_input for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) s_input def s_row(N): return [s_input for _ in range(N)] s_row N N s_list() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) s_list() s_list def s_row_str(N): return [s_list() for _ in range(N)] s_row_str N N list(s_input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) list(s_input()) list s_input() s_input def s_row_list(N): return [list(s_input()) for _ in range(N)] s_row_list N N def main():
    import bisect
    n = i_input()
    l = sorted(i_list())
    ans = 0
    for a in range(n-2):
        for b in range(a+1,n-1):
            ans += bisect.bisect(l, l[a]+l[b]-1) -b-1
    print(ans) main import bisect bisect n = i_input() n i_input() i_input l = sorted(i_list()) l sorted(i_list()) sorted i_list() i_list ans = 0 ans 0 for a in range(n-2):
        for b in range(a+1,n-1):
            ans += bisect.bisect(l, l[a]+l[b]-1) -b-1
     a range(n-2) range n-2 n 2 for b in range(a+1,n-1):
            ans += bisect.bisect(l, l[a]+l[b]-1) -b-1
     b range(a+1,n-1) range a+1 a 1 n-1 n 1 ans += bisect.bisect(l, l[a]+l[b]-1) -b-1 ans bisect.bisect(l, l[a]+l[b]-1) -b-1 bisect.bisect(l, l[a]+l[b]-1) -b bisect.bisect(l, l[a]+l[b]-1) bisect.bisect bisect bisect l l[a]+l[b]-1 l[a]+l[b] l[a] l a l[b] l b 1 b 1 print(ans) print ans if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def i_list(): return list(i_map()) def i_list(): return list(i_map()) i_list def main():
    import bisect
    n = i_input()
    l = sorted(i_list())
    ans = 0
    for a in range(n-2):
        for b in range(a+1,n-1):
            ans += bisect.bisect(l, l[a]+l[b]-1) -b-1
    print(ans) def main():
    import bisect
    n = i_input()
    l = sorted(i_list())
    ans = 0
    for a in range(n-2):
        for b in range(a+1,n-1):
            ans += bisect.bisect(l, l[a]+l[b]-1) -b-1
    print(ans) main def i_map(): return map(int, input().split()) def i_map(): return map(int, input().split()) i_map def s_map(): return input().split() def s_map(): return input().split() s_map def i_row_list(N): return [i_list() for _ in range(N)] def i_row_list(N): return [i_list() for _ in range(N)] i_row_list INF = float("inf") float("inf") INF def s_input(): return input() def s_input(): return input() s_input def s_row_list(N): return [list(s_input()) for _ in range(N)] def s_row_list(N): return [list(s_input()) for _ in range(N)] s_row_list def s_row_str(N): return [s_list() for _ in range(N)] def s_row_str(N): return [s_list() for _ in range(N)] s_row_str def i_input(): return int(input()) def i_input(): return int(input()) i_input def s_list(): return list(s_map()) def s_list(): return list(s_map()) s_list def s_row(N): return [s_input for _ in range(N)] def s_row(N): return [s_input for _ in range(N)] s_row def i_row(N): return [i_input() for _ in range(N)] def i_row(N): return [i_input() for _ in range(N)] i_row
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    import bisect
    n = i_input()
    l = sorted(i_list())
    ans = 0
    for a in range(n-2):
        for b in range(a+1,n-1):
            ans += bisect.bisect(l, l[a]+l[b]-1) -b-1
    print(ans)

if __name__=="__main__":
    main()
