import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
def sub(x):
    j = n-1
    ans = 0
    for i in range(x+1, n-1):
        if j<=i:
            break
        while j-1>i and l[i]+l[j]<=l[x]:
            j -= 1
        if i<j and l[i]+l[j]>l[x]:
            ans += (j-i)
#         print(i,j)
    return ans
ans = 0
for x in range(n-2):
    ans += sub(x)
#     print(ans)
print(ans) import sys sys input = lambda : sys.stdin.readline().rstrip() input lambda : sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip sys.setrecursionlimit(max(1000, 10**9)) sys.setrecursionlimit sys setrecursionlimit max(1000, 10**9) max 1000 10**9 10 9 write = lambda x: sys.stdout.write(x+"\n") write lambda x: sys.stdout.write(x+"\n") sys.stdout.write(x+"\n") sys.stdout.write sys.stdout sys stdout write x+"\n" x "\n" x 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(reverse=True) l.sort l sort reverse=True reverse True def sub(x):
    j = n-1
    ans = 0
    for i in range(x+1, n-1):
        if j<=i:
            break
        while j-1>i and l[i]+l[j]<=l[x]:
            j -= 1
        if i<j and l[i]+l[j]>l[x]:
            ans += (j-i)
#         print(i,j)
    return ans sub j = n-1 j n-1 n 1 ans = 0 ans 0 for i in range(x+1, n-1):
        if j<=i:
            break
        while j-1>i and l[i]+l[j]<=l[x]:
            j -= 1
        if i<j and l[i]+l[j]>l[x]:
            ans += (j-i)
#         print(i,j)
     i range(x+1, n-1) range x+1 x 1 n-1 n 1 if j<=i:
            break
         j<=i j i break while j-1>i and l[i]+l[j]<=l[x]:
            j -= 1
         j-1>i and l[i]+l[j]<=l[x] j-1>i j-1 j 1 i l[i]+l[j]<=l[x] l[i]+l[j] l[i] l i l[j] l j l[x] l x j -= 1 j 1 if i<j and l[i]+l[j]>l[x]:
            ans += (j-i)
#         print(i,j)
     i<j and l[i]+l[j]>l[x] i<j i j l[i]+l[j]>l[x] l[i]+l[j] l[i] l i l[j] l j l[x] l x ans += (j-i) ans j-i j i return ans ans x x ans = 0 ans 0 for x in range(n-2):
    ans += sub(x)
#     print(ans) x range(n-2) range n-2 n 2 ans += sub(x) ans sub(x) sub x print(ans) print ans l = list(map(int, input().split())) list(map(int, input().split())) l input = lambda : sys.stdin.readline().rstrip() lambda : sys.stdin.readline().rstrip() input write = lambda x: sys.stdout.write(x+"\n") lambda x: sys.stdout.write(x+"\n") write ans += sub(x) sub(x) ans def sub(x):
    j = n-1
    ans = 0
    for i in range(x+1, n-1):
        if j<=i:
            break
        while j-1>i and l[i]+l[j]<=l[x]:
            j -= 1
        if i<j and l[i]+l[j]>l[x]:
            ans += (j-i)
#         print(i,j)
    return ans def sub(x):
    j = n-1
    ans = 0
    for i in range(x+1, n-1):
        if j<=i:
            break
        while j-1>i and l[i]+l[j]<=l[x]:
            j -= 1
        if i<j and l[i]+l[j]>l[x]:
            ans += (j-i)
#         print(i,j)
    return ans sub n = int(input()) int(input()) n ans = 0 0 ans
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
def sub(x):
    j = n-1
    ans = 0
    for i in range(x+1, n-1):
        if j<=i:
            break
        while j-1>i and l[i]+l[j]<=l[x]:
            j -= 1
        if i<j and l[i]+l[j]>l[x]:
            ans += (j-i)
#         print(i,j)
    return ans
ans = 0
for x in range(n-2):
    ans += sub(x)
#     print(ans)
print(ans)