from bisect import bisect_right
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    *L, = map(int, input().split())
    L.sort()
    ans = 0
    for i in range(2, N):
        for j in range(i):
            k = bisect_right(L, L[i] - L[j], j + 1, i)
            ans += i - k
    print(ans)

if __name__ == '__main__':
    main() from bisect import bisect_right import sys sys def main():
    input = sys.stdin.readline
    N = int(input())
    *L, = map(int, input().split())
    L.sort()
    ans = 0
    for i in range(2, N):
        for j in range(i):
            k = bisect_right(L, L[i] - L[j], j + 1, i)
            ans += i - k
    print(ans) main input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input *L, = map(int, input().split()) *L L map(int, input().split()) map int input().split() ().split () input split L.sort() L.sort L sort ans = 0 ans 0 for i in range(2, N):
        for j in range(i):
            k = bisect_right(L, L[i] - L[j], j + 1, i)
            ans += i - k
     i range(2, N) range 2 N for j in range(i):
            k = bisect_right(L, L[i] - L[j], j + 1, i)
            ans += i - k
     j range(i) range i k = bisect_right(L, L[i] - L[j], j + 1, i) k bisect_right(L, L[i] - L[j], j + 1, i) bisect_right L L[i] - L[j] L[i] L i L[j] L j j + 1 j 1 i ans += i - k ans i - k i k print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    input = sys.stdin.readline
    N = int(input())
    *L, = map(int, input().split())
    L.sort()
    ans = 0
    for i in range(2, N):
        for j in range(i):
            k = bisect_right(L, L[i] - L[j], j + 1, i)
            ans += i - k
    print(ans) def main():
    input = sys.stdin.readline
    N = int(input())
    *L, = map(int, input().split())
    L.sort()
    ans = 0
    for i in range(2, N):
        for j in range(i):
            k = bisect_right(L, L[i] - L[j], j + 1, i)
            ans += i - k
    print(ans) main
from bisect import bisect_right
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    *L, = map(int, input().split())
    L.sort()
    ans = 0
    for i in range(2, N):
        for j in range(i):
            k = bisect_right(L, L[i] - L[j], j + 1, i)
            ans += i - k
    print(ans)

if __name__ == '__main__':
    main()
