import sys
from itertools import accumulate

read = sys.stdin.buffer.read


def main():
    N, *L = map(int, read().split())

    L.sort()
    max_L = L[-1]

    C = [0] * (max_L + 1)
    for l in L:
        C[l] += 1
    C = list(accumulate(C))

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if L[i] + L[j] > max_L:
                ans += N - j - 1
            else:
                ans += C[L[i] + L[j] - 1] - j - 1

    print(ans)
    return


if __name__ == '__main__':
    main() import sys sys from itertools import accumulate read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read def main():
    N, *L = map(int, read().split())

    L.sort()
    max_L = L[-1]

    C = [0] * (max_L + 1)
    for l in L:
        C[l] += 1
    C = list(accumulate(C))

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if L[i] + L[j] > max_L:
                ans += N - j - 1
            else:
                ans += C[L[i] + L[j] - 1] - j - 1

    print(ans)
    return main N, *L = map(int, read().split()) N map(int, read().split()) map int read().split() ().split () read split *L L L.sort() L.sort L sort max_L = L[-1] max_L L[-1] L -1 C = [0] * (max_L + 1) C [0] * (max_L + 1) [0] 0 max_L + 1 max_L 1 for l in L:
        C[l] += 1
     l L C[l] += 1 C[l] C l 1 C = list(accumulate(C)) C list(accumulate(C)) list accumulate(C) accumulate C ans = 0 ans 0 for i in range(N):
        for j in range(i + 1, N):
            if L[i] + L[j] > max_L:
                ans += N - j - 1
            else:
                ans += C[L[i] + L[j] - 1] - j - 1

     i range(N) range N for j in range(i + 1, N):
            if L[i] + L[j] > max_L:
                ans += N - j - 1
            else:
                ans += C[L[i] + L[j] - 1] - j - 1

     j range(i + 1, N) range i + 1 i 1 N if L[i] + L[j] > max_L:
                ans += N - j - 1
            else:
                ans += C[L[i] + L[j] - 1] - j - 1

     L[i] + L[j] > max_L L[i] + L[j] L[i] L i L[j] L j max_L ans += N - j - 1 ans N - j - 1 N - j N j 1 ans += C[L[i] + L[j] - 1] - j - 1 ans C[L[i] + L[j] - 1] - j - 1 C[L[i] + L[j] - 1] - j C[L[i] + L[j] - 1] C L[i] + L[j] - 1 L[i] + L[j] L[i] L i L[j] L j 1 j 1 print(ans) print ans return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, *L = map(int, read().split())

    L.sort()
    max_L = L[-1]

    C = [0] * (max_L + 1)
    for l in L:
        C[l] += 1
    C = list(accumulate(C))

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if L[i] + L[j] > max_L:
                ans += N - j - 1
            else:
                ans += C[L[i] + L[j] - 1] - j - 1

    print(ans)
    return def main():
    N, *L = map(int, read().split())

    L.sort()
    max_L = L[-1]

    C = [0] * (max_L + 1)
    for l in L:
        C[l] += 1
    C = list(accumulate(C))

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if L[i] + L[j] > max_L:
                ans += N - j - 1
            else:
                ans += C[L[i] + L[j] - 1] - j - 1

    print(ans)
    return main read = sys.stdin.buffer.read sys.stdin.buffer.read read
import sys
from itertools import accumulate

read = sys.stdin.buffer.read


def main():
    N, *L = map(int, read().split())

    L.sort()
    max_L = L[-1]

    C = [0] * (max_L + 1)
    for l in L:
        C[l] += 1
    C = list(accumulate(C))

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if L[i] + L[j] > max_L:
                ans += N - j - 1
            else:
                ans += C[L[i] + L[j] - 1] - j - 1

    print(ans)
    return


if __name__ == '__main__':
    main()
