import bisect
from itertools import combinations

def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for l in combinations(L, 2):
        a = l[0]
        b = l[1]
        x = bisect.bisect_left(L, a + b)
        y = bisect.bisect(L, b - a)
        if b - a < a :
            ans += x - y - 2
        else:
            ans += x - y - 1
    print(ans // 3)


if __name__ == "__main__":
    main() import bisect bisect from itertools import combinations def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for l in combinations(L, 2):
        a = l[0]
        b = l[1]
        x = bisect.bisect_left(L, a + b)
        y = bisect.bisect(L, b - a)
        if b - a < a :
            ans += x - y - 2
        else:
            ans += x - y - 1
    print(ans // 3) main N = int(input()) N int(input()) int input() input L = sorted(list(map(int, input().split()))) L sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for l in combinations(L, 2):
        a = l[0]
        b = l[1]
        x = bisect.bisect_left(L, a + b)
        y = bisect.bisect(L, b - a)
        if b - a < a :
            ans += x - y - 2
        else:
            ans += x - y - 1
     l combinations(L, 2) combinations L 2 a = l[0] a l[0] l 0 b = l[1] b l[1] l 1 x = bisect.bisect_left(L, a + b) x bisect.bisect_left(L, a + b) bisect.bisect_left bisect bisect_left L a + b a b y = bisect.bisect(L, b - a) y bisect.bisect(L, b - a) bisect.bisect bisect bisect L b - a b a if b - a < a :
            ans += x - y - 2
        else:
            ans += x - y - 1
     b - a < a b - a b a a ans += x - y - 2 ans x - y - 2 x - y x y 2 ans += x - y - 1 ans x - y - 1 x - y x y 1 print(ans // 3) print ans // 3 ans 3 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for l in combinations(L, 2):
        a = l[0]
        b = l[1]
        x = bisect.bisect_left(L, a + b)
        y = bisect.bisect(L, b - a)
        if b - a < a :
            ans += x - y - 2
        else:
            ans += x - y - 1
    print(ans // 3) def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for l in combinations(L, 2):
        a = l[0]
        b = l[1]
        x = bisect.bisect_left(L, a + b)
        y = bisect.bisect(L, b - a)
        if b - a < a :
            ans += x - y - 2
        else:
            ans += x - y - 1
    print(ans // 3) main
import bisect
from itertools import combinations

def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for l in combinations(L, 2):
        a = l[0]
        b = l[1]
        x = bisect.bisect_left(L, a + b)
        y = bisect.bisect(L, b - a)
        if b - a < a :
            ans += x - y - 2
        else:
            ans += x - y - 1
    print(ans // 3)


if __name__ == "__main__":
    main()
