import sys
# sys.setrecursionlimit(100000)
import bisect


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    L = sorted(input_int_list())
    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            idx = bisect.bisect_left(L, L[i] + L[j])
            ans += idx - j - 1
    print(ans)
    return


if __name__ == "__main__":
    main() import sys sys import bisect bisect def input():
    return sys.stdin.readline().strip() input return sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip def input_int():
    return int(input()) input_int return int(input()) int(input()) int input() input def input_int_list():
    return [int(i) for i in input().split()] input_int_list int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i return [int(i) for i in input().split()] [int(i) for i in input().split()] def main():
    n = input_int()
    L = sorted(input_int_list())
    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            idx = bisect.bisect_left(L, L[i] + L[j])
            ans += idx - j - 1
    print(ans)
    return main n = input_int() n input_int() input_int L = sorted(input_int_list()) L sorted(input_int_list()) sorted input_int_list() input_int_list ans = 0 ans 0 for i in range(n - 2):
        for j in range(i + 1, n - 1):
            idx = bisect.bisect_left(L, L[i] + L[j])
            ans += idx - j - 1
     i range(n - 2) range n - 2 n 2 for j in range(i + 1, n - 1):
            idx = bisect.bisect_left(L, L[i] + L[j])
            ans += idx - j - 1
     j range(i + 1, n - 1) range i + 1 i 1 n - 1 n 1 idx = bisect.bisect_left(L, L[i] + L[j]) idx bisect.bisect_left(L, L[i] + L[j]) bisect.bisect_left bisect bisect_left L L[i] + L[j] L[i] L i L[j] L j ans += idx - j - 1 ans idx - j - 1 idx - j idx j 1 print(ans) print ans return if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def input_int_list():
    return [int(i) for i in input().split()] def input_int_list():
    return [int(i) for i in input().split()] input_int_list def main():
    n = input_int()
    L = sorted(input_int_list())
    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            idx = bisect.bisect_left(L, L[i] + L[j])
            ans += idx - j - 1
    print(ans)
    return def main():
    n = input_int()
    L = sorted(input_int_list())
    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            idx = bisect.bisect_left(L, L[i] + L[j])
            ans += idx - j - 1
    print(ans)
    return main def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input def input_int():
    return int(input()) def input_int():
    return int(input()) input_int
import sys
# sys.setrecursionlimit(100000)
import bisect


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    L = sorted(input_int_list())
    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            idx = bisect.bisect_left(L, L[i] + L[j])
            ans += idx - j - 1
    print(ans)
    return


if __name__ == "__main__":
    main()
