import bisect

def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for a_idx in range(N-2):
        for b_idx in range(a_idx+1, N-1):
            l_idx = b_idx + 1
            r_idx = bisect.bisect_left(L, L[a_idx] + L[b_idx])
            ans += r_idx - l_idx
    print(ans)


if __name__ == '__main__':
    main() import bisect bisect def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for a_idx in range(N-2):
        for b_idx in range(a_idx+1, N-1):
            l_idx = b_idx + 1
            r_idx = bisect.bisect_left(L, L[a_idx] + L[b_idx])
            ans += r_idx - l_idx
    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_idx in range(N-2):
        for b_idx in range(a_idx+1, N-1):
            l_idx = b_idx + 1
            r_idx = bisect.bisect_left(L, L[a_idx] + L[b_idx])
            ans += r_idx - l_idx
     a_idx range(N-2) range N-2 N 2 for b_idx in range(a_idx+1, N-1):
            l_idx = b_idx + 1
            r_idx = bisect.bisect_left(L, L[a_idx] + L[b_idx])
            ans += r_idx - l_idx
     b_idx range(a_idx+1, N-1) range a_idx+1 a_idx 1 N-1 N 1 l_idx = b_idx + 1 l_idx b_idx + 1 b_idx 1 r_idx = bisect.bisect_left(L, L[a_idx] + L[b_idx]) r_idx bisect.bisect_left(L, L[a_idx] + L[b_idx]) bisect.bisect_left bisect bisect_left L L[a_idx] + L[b_idx] L[a_idx] L a_idx L[b_idx] L b_idx ans += r_idx - l_idx ans r_idx - l_idx r_idx l_idx print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for a_idx in range(N-2):
        for b_idx in range(a_idx+1, N-1):
            l_idx = b_idx + 1
            r_idx = bisect.bisect_left(L, L[a_idx] + L[b_idx])
            ans += r_idx - l_idx
    print(ans) def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for a_idx in range(N-2):
        for b_idx in range(a_idx+1, N-1):
            l_idx = b_idx + 1
            r_idx = bisect.bisect_left(L, L[a_idx] + L[b_idx])
            ans += r_idx - l_idx
    print(ans) main
import bisect

def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for a_idx in range(N-2):
        for b_idx in range(a_idx+1, N-1):
            l_idx = b_idx + 1
            r_idx = bisect.bisect_left(L, L[a_idx] + L[b_idx])
            ans += r_idx - l_idx
    print(ans)


if __name__ == '__main__':
    main()
