import sys
from bisect import bisect_left

input = sys.stdin.readline


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

    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            x = bisect_left(L, L[a] + L[b])
            ans += (x - 1 - b)

    print(ans)


if __name__ == "__main__":
    main() import sys sys from bisect import bisect_left input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            x = bisect_left(L, L[a] + L[b])
            ans += (x - 1 - b)

    print(ans) main 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.sort() L.sort L sort ans = 0 ans 0 for a in range(N - 2):
        for b in range(a + 1, N - 1):
            x = bisect_left(L, L[a] + L[b])
            ans += (x - 1 - b)

     a range(N - 2) range N - 2 N 2 for b in range(a + 1, N - 1):
            x = bisect_left(L, L[a] + L[b])
            ans += (x - 1 - b)

     b range(a + 1, N - 1) range a + 1 a 1 N - 1 N 1 x = bisect_left(L, L[a] + L[b]) x bisect_left(L, L[a] + L[b]) bisect_left L L[a] + L[b] L[a] L a L[b] L b ans += (x - 1 - b) ans x - 1 - b x - 1 x 1 b print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main input = sys.stdin.readline sys.stdin.readline input def main():
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            x = bisect_left(L, L[a] + L[b])
            ans += (x - 1 - b)

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

    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            x = bisect_left(L, L[a] + L[b])
            ans += (x - 1 - b)

    print(ans) main
import sys
from bisect import bisect_left

input = sys.stdin.readline


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

    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            x = bisect_left(L, L[a] + L[b])
            ans += (x - 1 - b)

    print(ans)


if __name__ == "__main__":
    main()
