import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    L.sort()

    max_L = max(L)

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

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

    print(ans)
    return


if __name__ == '__main__':
    main() import sys sys from itertools import accumulate read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    N, *L = map(int, read().split())

    L.sort()

    max_L = max(L)

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

    ans = 0
    for i, a in enumerate(L):
        for j, b in enumerate(L[i + 1 :], i + 1):
            if a + b > max_L:
                ans += N - j - 1
            else:
                ans += C[a + b - 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 = max(L) max_L max(L) max L 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, a in enumerate(L):
        for j, b in enumerate(L[i + 1 :], i + 1):
            if a + b > max_L:
                ans += N - j - 1
            else:
                ans += C[a + b - 1] - j - 1

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

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

     a + b > max_L a + b a b max_L ans += N - j - 1 ans N - j - 1 N - j N j 1 ans += C[a + b - 1] - j - 1 ans C[a + b - 1] - j - 1 C[a + b - 1] - j C[a + b - 1] C a + b - 1 a + b a b 1 j 1 print(ans) print ans return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main INF = 1 << 60 1 << 60 INF read = sys.stdin.read sys.stdin.read read def main():
    N, *L = map(int, read().split())

    L.sort()

    max_L = max(L)

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

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

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

    L.sort()

    max_L = max(L)

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

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

    print(ans)
    return main MOD = 1000000007 1000000007 MOD readline = sys.stdin.readline sys.stdin.readline readline readlines = sys.stdin.readlines sys.stdin.readlines readlines
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    L.sort()

    max_L = max(L)

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

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

    print(ans)
    return


if __name__ == '__main__':
    main()
