N = int(input()) x = list(map(int,input().split())) s, s1 = 0, 0 for v in x : s1 += s * v s += v print((1 + 2 * s1 * pow(s, -1, 1000000007)) % 1000000007)