#!/usr/bin/env python3

import bisect

def main():
  N = int(input())
  L = list(sorted(map(int,input().split())))
  res = 0
  for i in range(N-2):
    x = L[i]
    for j in range(i+1,N-1):
      y = L[j]
      res += bisect.bisect_left(L,x+y) - j - 1


  print(res)
  return

main() import bisect bisect def main():
  N = int(input())
  L = list(sorted(map(int,input().split())))
  res = 0
  for i in range(N-2):
    x = L[i]
    for j in range(i+1,N-1):
      y = L[j]
      res += bisect.bisect_left(L,x+y) - j - 1


  print(res)
  return main N = int(input()) N int(input()) int input() input L = list(sorted(map(int,input().split()))) L list(sorted(map(int,input().split()))) list sorted(map(int,input().split())) sorted map(int,input().split()) map int input().split() ().split () input split res = 0 res 0 for i in range(N-2):
    x = L[i]
    for j in range(i+1,N-1):
      y = L[j]
      res += bisect.bisect_left(L,x+y) - j - 1


   i range(N-2) range N-2 N 2 x = L[i] x L[i] L i for j in range(i+1,N-1):
      y = L[j]
      res += bisect.bisect_left(L,x+y) - j - 1


   j range(i+1,N-1) range i+1 i 1 N-1 N 1 y = L[j] y L[j] L j res += bisect.bisect_left(L,x+y) - j - 1 res bisect.bisect_left(L,x+y) - j - 1 bisect.bisect_left(L,x+y) - j bisect.bisect_left(L,x+y) bisect.bisect_left bisect bisect_left L x+y x y j 1 print(res) print res return main() main def main():
  N = int(input())
  L = list(sorted(map(int,input().split())))
  res = 0
  for i in range(N-2):
    x = L[i]
    for j in range(i+1,N-1):
      y = L[j]
      res += bisect.bisect_left(L,x+y) - j - 1


  print(res)
  return def main():
  N = int(input())
  L = list(sorted(map(int,input().split())))
  res = 0
  for i in range(N-2):
    x = L[i]
    for j in range(i+1,N-1):
      y = L[j]
      res += bisect.bisect_left(L,x+y) - j - 1


  print(res)
  return main
#!/usr/bin/env python3

import bisect

def main():
  N = int(input())
  L = list(sorted(map(int,input().split())))
  res = 0
  for i in range(N-2):
    x = L[i]
    for j in range(i+1,N-1):
      y = L[j]
      res += bisect.bisect_left(L,x+y) - j - 1


  print(res)
  return

main()
