import qualified Data.IntMap as M
import qualified Data.ByteString.Lazy.Char8 as B
import Data.List
import Debug.Trace
import Test.QuickCheck

main = do
  _ <- getLine
  input <- B.getContents
  let as = map readInt . B.words $ input
  print (solve as)

readInt :: B.ByteString -> Int
readInt s = case B.readInt s of Just (n,_) -> n

solve :: [Int] -> Int
solve xs =
  fst $ foldl' f (0, M.empty) xs
  where
    f (c,m) v =
      let c' = c + (if v==0 then 1 else 0)
                 + case M.lookup (-v) m of
                     Just k -> k
                     Nothing -> 0
          m' = M.alter (g v) v (M.mapKeys (+v) m)
      in (c',m')

    g v Nothing  = Just 1
    g v (Just c) = Just (c+1)