import Data.Array
import Data.List

main = do
  getLine
  li <- getLine
  let ls = map read $ words li
  let ans =compute ls
  print ans

compute :: [Int] -> Int
compute ls = ans
  where
    ls1@(l0:l1:ls2) = sort ls
    ar0 = accumArray (+) 0 (2,2000) [(l0+l1,1)]
    (_,_,ans) = foldl' step (ar0,2,0) ls2

    step (ar,i,acc) c = (ar1, succ i, acc+cnt)
      where
        cnt = sum [ ar ! j | j <- [succ c..2000]]
        ar1 = accum (+) ar $ [ (c + j, 1) | j <- take i ls1 ]
