def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for ia in range(N-2):
        a = L[ia]
        ic = ia + 2
        for ib in range(ia+1, N-1):
            b = L[ib]
            while ic < N and L[ic] < a+b:
                ic += 1
            ans += ic - (ib + 1)
    print(ans)
main() def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for ia in range(N-2):
        a = L[ia]
        ic = ia + 2
        for ib in range(ia+1, N-1):
            b = L[ib]
            while ic < N and L[ic] < a+b:
                ic += 1
            ans += ic - (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-2):
        a = L[ia]
        ic = ia + 2
        for ib in range(ia+1, N-1):
            b = L[ib]
            while ic < N and L[ic] < a+b:
                ic += 1
            ans += ic - (ib + 1)
     ia range(N-2) range N-2 N 2 a = L[ia] a L[ia] L ia ic = ia + 2 ic ia + 2 ia 2 for ib in range(ia+1, N-1):
            b = L[ib]
            while ic < N and L[ic] < a+b:
                ic += 1
            ans += ic - (ib + 1)
     ib range(ia+1, N-1) range ia+1 ia 1 N-1 N 1 b = L[ib] b L[ib] L ib while ic < N and L[ic] < a+b:
                ic += 1
             ic < N and L[ic] < a+b ic < N ic N L[ic] < a+b L[ic] L ic a+b a b ic += 1 ic 1 ans += ic - (ib + 1) ans ic - (ib + 1) ic 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-2):
        a = L[ia]
        ic = ia + 2
        for ib in range(ia+1, N-1):
            b = L[ib]
            while ic < N and L[ic] < a+b:
                ic += 1
            ans += ic - (ib + 1)
    print(ans) def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for ia in range(N-2):
        a = L[ia]
        ic = ia + 2
        for ib in range(ia+1, N-1):
            b = L[ib]
            while ic < N and L[ic] < a+b:
                ic += 1
            ans += ic - (ib + 1)
    print(ans) main
def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for ia in range(N-2):
        a = L[ia]
        ic = ia + 2
        for ib in range(ia+1, N-1):
            b = L[ib]
            while ic < N and L[ic] < a+b:
                ic += 1
            ans += ic - (ib + 1)
    print(ans)
main()