main :: IO ()
main = do
    n <- readLn
    a <- getLine >>= return . words >>=  return . map read :: IO [Int]
    print $ solve n a

solve :: Int -> [Int] -> Int
solve n xs = (`mod` m) . sum . nub $ list xs
  where
    m = 1000000007
    list []     = []
    list (y:ys) = [x * y `mod` m| x <- ys] ++ list ys
