import bisect
n = int(input())
lines = list(int(i) for i in input().split())
lines.sort()
counter = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1)
    
print(counter) import bisect bisect n = int(input()) n int(input()) int input() input lines = list(int(i) for i in input().split()) lines list(int(i) for i in input().split()) list int(i) int i lines.sort() lines.sort lines sort counter = 0 counter 0 for i in range(n-2):
  for j in range(i+1, n-1):
    counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1)
     i range(n-2) range n-2 n 2 for j in range(i+1, n-1):
    counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1)
     j range(i+1, n-1) range i+1 i 1 n-1 n 1 counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1) counter bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1) bisect.bisect_left(lines, lines[i] + lines[j]) bisect.bisect_left bisect bisect_left lines lines[i] + lines[j] lines[i] lines i lines[j] lines j j + 1 j 1 print(counter) print counter counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1) bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1) counter counter = 0 0 counter n = int(input()) int(input()) n lines = list(int(i) for i in input().split()) list(int(i) for i in input().split()) lines
import bisect
n = int(input())
lines = list(int(i) for i in input().split())
lines.sort()
counter = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1)
    
print(counter)