# -*- 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(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

""" import sys sys from collections import deque, defaultdict from math import sqrt, factorial, gcd, ceil import string string from bisect import bisect_left def solve():
    n = int(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) solve n = int(input()) n int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x l = [int(x) for x in input().split()] l [int(x) for x in input().split()] l.sort() l.sort l sort ans = 0 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
     i range(n) range n for j in range(i + 1, n):
            r = bisect_left(l, l[i] + l[j])
            if r > j:
                ans += r - j - 1
     j range(i + 1, n) range i + 1 i 1 n r = bisect_left(l, l[i] + l[j]) r bisect_left(l, l[i] + l[j]) bisect_left l l[i] + l[j] l[i] l i l[j] l j if r > j:
                ans += r - j - 1
     r > j r j ans += r - j - 1 ans r - j - 1 r - j r j 1 print(ans) print ans t = 1 t 1 for case in range(1,t+1):
    ans = solve() case range(1,t+1) range 1 t+1 t 1 ans = solve() ans solve() solve """

azyxwvutsrqponmlkjihgfedcb

""" t = 1 1 t def solve():
    n = int(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) def solve():
    n = int(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) solve ans = solve() solve() ans
# -*- 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(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

"""
