def main():
    import bisect
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            c = bisect.bisect_left(inlis, inlis[a] + inlis[b])
            ans += c - b - 1
    print(ans)     



if __name__ == "__main__":
    main() def main():
    import bisect
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            c = bisect.bisect_left(inlis, inlis[a] + inlis[b])
            ans += c - b - 1
    print(ans)      main import bisect bisect n = int(input()) n int(input()) int input() input inlis = list(map(int, input().split())) inlis list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split inlis.sort() inlis.sort inlis sort ans = 0 ans 0 for a in range(n):
        for b in range(a+1, n):
            c = bisect.bisect_left(inlis, inlis[a] + inlis[b])
            ans += c - b - 1
     a range(n) range n for b in range(a+1, n):
            c = bisect.bisect_left(inlis, inlis[a] + inlis[b])
            ans += c - b - 1
     b range(a+1, n) range a+1 a 1 n c = bisect.bisect_left(inlis, inlis[a] + inlis[b]) c bisect.bisect_left(inlis, inlis[a] + inlis[b]) bisect.bisect_left bisect bisect_left inlis inlis[a] + inlis[b] inlis[a] inlis a inlis[b] inlis b ans += c - b - 1 ans c - b - 1 c - b c b 1 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    import bisect
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            c = bisect.bisect_left(inlis, inlis[a] + inlis[b])
            ans += c - b - 1
    print(ans)      def main():
    import bisect
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            c = bisect.bisect_left(inlis, inlis[a] + inlis[b])
            ans += c - b - 1
    print(ans)      main
def main():
    import bisect
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            c = bisect.bisect_left(inlis, inlis[a] + inlis[b])
            ans += c - b - 1
    print(ans)     



if __name__ == "__main__":
    main()
