#!/usr/bin/env python3
import bisect


def main():
    N = int(input())
    L = sorted(map(int, input().split()))
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_right(L, L[a] + L[b] - 1) - b - 1

    print(ans)


if __name__ == "__main__":
    main() import bisect bisect def main():
    N = int(input())
    L = sorted(map(int, input().split()))
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_right(L, L[a] + L[b] - 1) - b - 1

    print(ans) main N = int(input()) N int(input()) int input() input L = sorted(map(int, input().split())) L sorted(map(int, input().split())) sorted map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_right(L, L[a] + L[b] - 1) - b - 1

     a range(N - 2) range N - 2 N 2 for b in range(a + 1, N - 1):
            ans += bisect.bisect_right(L, L[a] + L[b] - 1) - b - 1

     b range(a + 1, N - 1) range a + 1 a 1 N - 1 N 1 ans += bisect.bisect_right(L, L[a] + L[b] - 1) - b - 1 ans bisect.bisect_right(L, L[a] + L[b] - 1) - b - 1 bisect.bisect_right(L, L[a] + L[b] - 1) - b bisect.bisect_right(L, L[a] + L[b] - 1) bisect.bisect_right bisect bisect_right L L[a] + L[b] - 1 L[a] + L[b] L[a] L a L[b] L b 1 b 1 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    L = sorted(map(int, input().split()))
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_right(L, L[a] + L[b] - 1) - b - 1

    print(ans) def main():
    N = int(input())
    L = sorted(map(int, input().split()))
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_right(L, L[a] + L[b] - 1) - b - 1

    print(ans) main
#!/usr/bin/env python3
import bisect


def main():
    N = int(input())
    L = sorted(map(int, input().split()))
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_right(L, L[a] + L[b] - 1) - b - 1

    print(ans)


if __name__ == "__main__":
    main()
