import bisect
import sys
from bisect import bisect_left
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]

def main():
    N = ii()
    L = lmi()
    L.sort()
    # print(L)
    # 2辺を固定して、2辺の和より長い辺の数を数える
    count = 0
    for i in range(N):
        for j in range(i+1, N):
            limit = L[i] + L[j]
            longer = bisect_left(L, limit)
            tmp = longer - (j + 1)
            # print(limit, longer, tmp)
            count += longer - (j + 1)

    print(count)
    return

main() import bisect bisect import sys sys from bisect import bisect_left from operator import itemgetter sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def ii(): return int(input()) ii def mi(): return map(int, input().split()) mi def lmi(): return list(map(int, input().split())) lmi list(map(int, input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def lmif(n): return [list(map(int, input().split())) for _ in range(n)] lmif n n def main():
    N = ii()
    L = lmi()
    L.sort()
    # print(L)
    # 2辺を固定して、2辺の和より長い辺の数を数える
    count = 0
    for i in range(N):
        for j in range(i+1, N):
            limit = L[i] + L[j]
            longer = bisect_left(L, limit)
            tmp = longer - (j + 1)
            # print(limit, longer, tmp)
            count += longer - (j + 1)

    print(count)
    return main N = ii() N ii() ii L = lmi() L lmi() lmi L.sort() L.sort L sort count = 0 count 0 for i in range(N):
        for j in range(i+1, N):
            limit = L[i] + L[j]
            longer = bisect_left(L, limit)
            tmp = longer - (j + 1)
            # print(limit, longer, tmp)
            count += longer - (j + 1)

     i range(N) range N for j in range(i+1, N):
            limit = L[i] + L[j]
            longer = bisect_left(L, limit)
            tmp = longer - (j + 1)
            # print(limit, longer, tmp)
            count += longer - (j + 1)

     j range(i+1, N) range i+1 i 1 N limit = L[i] + L[j] limit L[i] + L[j] L[i] L i L[j] L j longer = bisect_left(L, limit) longer bisect_left(L, limit) bisect_left L limit tmp = longer - (j + 1) tmp longer - (j + 1) longer j + 1 j 1 count += longer - (j + 1) count longer - (j + 1) longer j + 1 j 1 print(count) print count return main() main def ii(): return int(input()) def ii(): return int(input()) ii def mi(): return map(int, input().split()) def mi(): return map(int, input().split()) mi def lmi(): return list(map(int, input().split())) def lmi(): return list(map(int, input().split())) lmi def lmif(n): return [list(map(int, input().split())) for _ in range(n)] def lmif(n): return [list(map(int, input().split())) for _ in range(n)] lmif input = sys.stdin.readline sys.stdin.readline input def main():
    N = ii()
    L = lmi()
    L.sort()
    # print(L)
    # 2辺を固定して、2辺の和より長い辺の数を数える
    count = 0
    for i in range(N):
        for j in range(i+1, N):
            limit = L[i] + L[j]
            longer = bisect_left(L, limit)
            tmp = longer - (j + 1)
            # print(limit, longer, tmp)
            count += longer - (j + 1)

    print(count)
    return def main():
    N = ii()
    L = lmi()
    L.sort()
    # print(L)
    # 2辺を固定して、2辺の和より長い辺の数を数える
    count = 0
    for i in range(N):
        for j in range(i+1, N):
            limit = L[i] + L[j]
            longer = bisect_left(L, limit)
            tmp = longer - (j + 1)
            # print(limit, longer, tmp)
            count += longer - (j + 1)

    print(count)
    return main
import bisect
import sys
from bisect import bisect_left
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]

def main():
    N = ii()
    L = lmi()
    L.sort()
    # print(L)
    # 2辺を固定して、2辺の和より長い辺の数を数える
    count = 0
    for i in range(N):
        for j in range(i+1, N):
            limit = L[i] + L[j]
            longer = bisect_left(L, limit)
            tmp = longer - (j + 1)
            # print(limit, longer, tmp)
            count += longer - (j + 1)

    print(count)
    return

main()
