#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

from bisect import bisect_right

def main():
    N = int(input())
    L = list(map(int,input().split()))

    L.sort()
    ans = 0
    for b in range(N):
        for a in range(b+1,N):
            upper = b
            lower = bisect_right(L, L[a] - L[b])
            ans += max(0, upper - lower)
    
    print(ans)
    
if __name__ == "__main__":
    main() import sys sys input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 INF = float("inf") INF float("inf") float "inf" from bisect import bisect_right def main():
    N = int(input())
    L = list(map(int,input().split()))

    L.sort()
    ans = 0
    for b in range(N):
        for a in range(b+1,N):
            upper = b
            lower = bisect_right(L, L[a] - L[b])
            ans += max(0, upper - lower)
    
    print(ans)
     main 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 b in range(N):
        for a in range(b+1,N):
            upper = b
            lower = bisect_right(L, L[a] - L[b])
            ans += max(0, upper - lower)
    
     b range(N) range N for a in range(b+1,N):
            upper = b
            lower = bisect_right(L, L[a] - L[b])
            ans += max(0, upper - lower)
    
     a range(b+1,N) range b+1 b 1 N upper = b upper b lower = bisect_right(L, L[a] - L[b]) lower bisect_right(L, L[a] - L[b]) bisect_right L L[a] - L[b] L[a] L a L[b] L b ans += max(0, upper - lower) ans max(0, upper - lower) max 0 upper - lower upper lower print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main input = sys.stdin.buffer.readline sys.stdin.buffer.readline input INF = float("inf") float("inf") INF def main():
    N = int(input())
    L = list(map(int,input().split()))

    L.sort()
    ans = 0
    for b in range(N):
        for a in range(b+1,N):
            upper = b
            lower = bisect_right(L, L[a] - L[b])
            ans += max(0, upper - lower)
    
    print(ans)
     def main():
    N = int(input())
    L = list(map(int,input().split()))

    L.sort()
    ans = 0
    for b in range(N):
        for a in range(b+1,N):
            upper = b
            lower = bisect_right(L, L[a] - L[b])
            ans += max(0, upper - lower)
    
    print(ans)
     main
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

from bisect import bisect_right

def main():
    N = int(input())
    L = list(map(int,input().split()))

    L.sort()
    ans = 0
    for b in range(N):
        for a in range(b+1,N):
            upper = b
            lower = bisect_right(L, L[a] - L[b])
            ans += max(0, upper - lower)
    
    print(ans)
    
if __name__ == "__main__":
    main()