from bisect import bisect_left

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

    ans = 0
    for ia in range(N):
        for ib in range(ia+1, N-1):
            a = L[ia]
            b = L[ib]
            ic_end = bisect_left(L, a+b, lo=ib+1)
            ans += ic_end - (ib+1)

    print(ans)
main() from bisect import bisect_left def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))

    ans = 0
    for ia in range(N):
        for ib in range(ia+1, N-1):
            a = L[ia]
            b = L[ib]
            ic_end = bisect_left(L, a+b, lo=ib+1)
            ans += ic_end - (ib+1)

    print(ans) main N = int(input()) N int(input()) int input() input L = sorted(list(map(int, input().split()))) L sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for ia in range(N):
        for ib in range(ia+1, N-1):
            a = L[ia]
            b = L[ib]
            ic_end = bisect_left(L, a+b, lo=ib+1)
            ans += ic_end - (ib+1)

     ia range(N) range N for ib in range(ia+1, N-1):
            a = L[ia]
            b = L[ib]
            ic_end = bisect_left(L, a+b, lo=ib+1)
            ans += ic_end - (ib+1)

     ib range(ia+1, N-1) range ia+1 ia 1 N-1 N 1 a = L[ia] a L[ia] L ia b = L[ib] b L[ib] L ib ic_end = bisect_left(L, a+b, lo=ib+1) ic_end bisect_left(L, a+b, lo=ib+1) bisect_left L a+b a b lo=ib+1 lo ib+1 ib 1 ans += ic_end - (ib+1) ans ic_end - (ib+1) ic_end ib+1 ib 1 print(ans) print ans main() main def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))

    ans = 0
    for ia in range(N):
        for ib in range(ia+1, N-1):
            a = L[ia]
            b = L[ib]
            ic_end = bisect_left(L, a+b, lo=ib+1)
            ans += ic_end - (ib+1)

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

    ans = 0
    for ia in range(N):
        for ib in range(ia+1, N-1):
            a = L[ia]
            b = L[ib]
            ic_end = bisect_left(L, a+b, lo=ib+1)
            ans += ic_end - (ib+1)

    print(ans) main
from bisect import bisect_left

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

    ans = 0
    for ia in range(N):
        for ib in range(ia+1, N-1):
            a = L[ia]
            b = L[ib]
            ic_end = bisect_left(L, a+b, lo=ib+1)
            ans += ic_end - (ib+1)

    print(ans)
main()