import bisect
def main2():
    N = int(input())
    L = list(map(int, input().split()))
    L = sorted(L)

    ans = 0
    for i in range(len(L) - 2):
        for j in range(i + 1, len(L) - 1):
            ab = L[i] + L[j]
            r = bisect.bisect_left(L, ab)
            l = j + 1
            ans += r - l

    print(ans)

if __name__ == "__main__":
    main2() import bisect bisect def main2():
    N = int(input())
    L = list(map(int, input().split()))
    L = sorted(L)

    ans = 0
    for i in range(len(L) - 2):
        for j in range(i + 1, len(L) - 1):
            ab = L[i] + L[j]
            r = bisect.bisect_left(L, ab)
            l = j + 1
            ans += r - l

    print(ans) main2 N = int(input()) N int(input()) int input() input L = list(map(int, input().split())) L list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L = sorted(L) L sorted(L) sorted L ans = 0 ans 0 for i in range(len(L) - 2):
        for j in range(i + 1, len(L) - 1):
            ab = L[i] + L[j]
            r = bisect.bisect_left(L, ab)
            l = j + 1
            ans += r - l

     i range(len(L) - 2) range len(L) - 2 len(L) len L 2 for j in range(i + 1, len(L) - 1):
            ab = L[i] + L[j]
            r = bisect.bisect_left(L, ab)
            l = j + 1
            ans += r - l

     j range(i + 1, len(L) - 1) range i + 1 i 1 len(L) - 1 len(L) len L 1 ab = L[i] + L[j] ab L[i] + L[j] L[i] L i L[j] L j r = bisect.bisect_left(L, ab) r bisect.bisect_left(L, ab) bisect.bisect_left bisect bisect_left L ab l = j + 1 l j + 1 j 1 ans += r - l ans r - l r l print(ans) print ans if __name__ == "__main__":
    main2() __name__ == "__main__" __name__ "__main__" main2() main2 def main2():
    N = int(input())
    L = list(map(int, input().split()))
    L = sorted(L)

    ans = 0
    for i in range(len(L) - 2):
        for j in range(i + 1, len(L) - 1):
            ab = L[i] + L[j]
            r = bisect.bisect_left(L, ab)
            l = j + 1
            ans += r - l

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

    ans = 0
    for i in range(len(L) - 2):
        for j in range(i + 1, len(L) - 1):
            ab = L[i] + L[j]
            r = bisect.bisect_left(L, ab)
            l = j + 1
            ans += r - l

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

    ans = 0
    for i in range(len(L) - 2):
        for j in range(i + 1, len(L) - 1):
            ab = L[i] + L[j]
            r = bisect.bisect_left(L, ab)
            l = j + 1
            ans += r - l

    print(ans)

if __name__ == "__main__":
    main2()