from bisect import bisect_left

n = int(input())
arr = list(map(int, input().split()))
arr.sort()

ans = 0
for small in range(n - 2):
    for mid in range(small + 1, n - 1):
        div = bisect_left(arr, arr[small] + arr[mid], 0, n)
        if div > mid + 1:
            ans += div - mid - 1

print(ans) from bisect import bisect_left n = int(input()) n int(input()) int input() input arr = list(map(int, input().split())) arr list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split arr.sort() arr.sort arr sort ans = 0 ans 0 for small in range(n - 2):
    for mid in range(small + 1, n - 1):
        div = bisect_left(arr, arr[small] + arr[mid], 0, n)
        if div > mid + 1:
            ans += div - mid - 1 small range(n - 2) range n - 2 n 2 for mid in range(small + 1, n - 1):
        div = bisect_left(arr, arr[small] + arr[mid], 0, n)
        if div > mid + 1:
            ans += div - mid - 1 mid range(small + 1, n - 1) range small + 1 small 1 n - 1 n 1 div = bisect_left(arr, arr[small] + arr[mid], 0, n) div bisect_left(arr, arr[small] + arr[mid], 0, n) bisect_left arr arr[small] + arr[mid] arr[small] arr small arr[mid] arr mid 0 n if div > mid + 1:
            ans += div - mid - 1 div > mid + 1 div mid + 1 mid 1 ans += div - mid - 1 ans div - mid - 1 div - mid div mid 1 print(ans) print ans ans = 0 0 ans div = bisect_left(arr, arr[small] + arr[mid], 0, n) bisect_left(arr, arr[small] + arr[mid], 0, n) div arr = list(map(int, input().split())) list(map(int, input().split())) arr ans += div - mid - 1 div - mid - 1 ans n = int(input()) int(input()) n
from bisect import bisect_left

n = int(input())
arr = list(map(int, input().split()))
arr.sort()

ans = 0
for small in range(n - 2):
    for mid in range(small + 1, n - 1):
        div = bisect_left(arr, arr[small] + arr[mid], 0, n)
        if div > mid + 1:
            ans += div - mid - 1

print(ans)