import sys
from itertools import combinations
import bisect


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    ans = 0
    for i, j in combinations(l, 2):
        lb = abs(j - i)
        ub = i + j
        ans += bisect.bisect_left(l, ub) - bisect.bisect_right(l, lb)
        for e in (i, j):
            if e > lb:
                ans -= 1

    print(ans // 3)


if __name__ == "__main__":
    main() import sys sys from itertools import combinations import bisect bisect def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    ans = 0
    for i, j in combinations(l, 2):
        lb = abs(j - i)
        ub = i + j
        ans += bisect.bisect_left(l, ub) - bisect.bisect_right(l, lb)
        for e in (i, j):
            if e > lb:
                ans -= 1

    print(ans // 3) main input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline 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 i, j in combinations(l, 2):
        lb = abs(j - i)
        ub = i + j
        ans += bisect.bisect_left(l, ub) - bisect.bisect_right(l, lb)
        for e in (i, j):
            if e > lb:
                ans -= 1

     i j combinations(l, 2) combinations l 2 lb = abs(j - i) lb abs(j - i) abs j - i j i ub = i + j ub i + j i j ans += bisect.bisect_left(l, ub) - bisect.bisect_right(l, lb) ans bisect.bisect_left(l, ub) - bisect.bisect_right(l, lb) bisect.bisect_left(l, ub) bisect.bisect_left bisect bisect_left l ub bisect.bisect_right(l, lb) bisect.bisect_right bisect bisect_right l lb for e in (i, j):
            if e > lb:
                ans -= 1

     e (i, j) i j if e > lb:
                ans -= 1

     e > lb e lb ans -= 1 ans 1 print(ans // 3) print ans // 3 ans 3 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    ans = 0
    for i, j in combinations(l, 2):
        lb = abs(j - i)
        ub = i + j
        ans += bisect.bisect_left(l, ub) - bisect.bisect_right(l, lb)
        for e in (i, j):
            if e > lb:
                ans -= 1

    print(ans // 3) def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    ans = 0
    for i, j in combinations(l, 2):
        lb = abs(j - i)
        ub = i + j
        ans += bisect.bisect_left(l, ub) - bisect.bisect_right(l, lb)
        for e in (i, j):
            if e > lb:
                ans -= 1

    print(ans // 3) main
import sys
from itertools import combinations
import bisect


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    ans = 0
    for i, j in combinations(l, 2):
        lb = abs(j - i)
        ub = i + j
        ans += bisect.bisect_left(l, ub) - bisect.bisect_right(l, lb)
        for e in (i, j):
            if e > lb:
                ans -= 1

    print(ans // 3)


if __name__ == "__main__":
    main()
