class Integer def mod_inverse(mod) self.pow(mod - 2, mod) end end N = gets.to_i X = gets.split.map(&:to_i) S = X.sum T = S ** 2 - X.map { |x| x ** 2 }.sum MOD = 10 ** 9 + 7 res = Rational(T, S) + 1 a = res.denominator b = res.numerator puts b * a.mod_inverse(MOD) % MOD