import bisect
n = int(input())
edges = sorted(list(map(int, input().split(' '))))
ans = 0
for i in range(n-1, -1, -1):
  for j in range(i-1, -1, -1):
    limit = edges[i] - edges[j]
    if limit < edges[j]:
      index = bisect.bisect_right(edges, limit)
      ans += max(0, j - index)  # maxいらんかも
print(ans) import bisect bisect n = int(input()) n int(input()) int input() input edges = sorted(list(map(int, input().split(' ')))) edges sorted(list(map(int, input().split(' ')))) sorted list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' ans = 0 ans 0 for i in range(n-1, -1, -1):
  for j in range(i-1, -1, -1):
    limit = edges[i] - edges[j]
    if limit < edges[j]:
      index = bisect.bisect_right(edges, limit)
      ans += max(0, j - index)  # maxいらんかも i range(n-1, -1, -1) range n-1 n 1 -1 -1 for j in range(i-1, -1, -1):
    limit = edges[i] - edges[j]
    if limit < edges[j]:
      index = bisect.bisect_right(edges, limit)
      ans += max(0, j - index)  # maxいらんかも j range(i-1, -1, -1) range i-1 i 1 -1 -1 limit = edges[i] - edges[j] limit edges[i] - edges[j] edges[i] edges i edges[j] edges j if limit < edges[j]:
      index = bisect.bisect_right(edges, limit)
      ans += max(0, j - index)  # maxいらんかも limit < edges[j] limit edges[j] edges j index = bisect.bisect_right(edges, limit) index bisect.bisect_right(edges, limit) bisect.bisect_right bisect bisect_right edges limit ans += max(0, j - index) ans max(0, j - index) max 0 j - index j index print(ans) print ans ans = 0 0 ans index = bisect.bisect_right(edges, limit) bisect.bisect_right(edges, limit) index ans += max(0, j - index) max(0, j - index) ans limit = edges[i] - edges[j] edges[i] - edges[j] limit edges = sorted(list(map(int, input().split(' ')))) sorted(list(map(int, input().split(' ')))) edges n = int(input()) int(input()) n
import bisect
n = int(input())
edges = sorted(list(map(int, input().split(' '))))
ans = 0
for i in range(n-1, -1, -1):
  for j in range(i-1, -1, -1):
    limit = edges[i] - edges[j]
    if limit < edges[j]:
      index = bisect.bisect_right(edges, limit)
      ans += max(0, j - index)  # maxいらんかも
print(ans)
