MOD = 10**9 + 7





def main():

    N = int(eval(input()))

    A = [int(i) for i in input().split()]

    from itertools import accumulate

    S = list(accumulate([0] + A))

    ans = 0

    for i in range(N-1):

        ans += A[i] * (S[N] - S[i+1])

        ans %= MOD

    print(ans)





if __name__ == '__main__':

    main()

MOD = 10**9 + 7





def main():

    _ = int(eval(input()))

    A = [int(i) for i in input().split()]



    ans = (sum(A)**2) % MOD - (sum(pow(a, 2, MOD) for a in A)) % MOD

    ans *= pow(2, MOD-2, MOD)

    ans %= MOD

    print(ans)





if __name__ == '__main__':

    main()

MOD = 10**9 + 7


def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    from itertools import accumulate

    S = list(accumulate([0] + A))
    ans = 0
    for i in range(N - 1):
        ans += A[i] * (S[N] - S[i + 1])
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

MOD = 10**9 + 7


def main():
    _ = int(eval(input()))
    A = [int(i) for i in input().split()]
    ans = (sum(A) ** 2) % MOD - (sum(pow(a, 2, MOD) for a in A)) % MOD
    ans *= pow(2, MOD - 2, MOD)
    ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

-    N = int(eval(input())) +    _ = int(eval(input())) -    from itertools import accumulate - -    S = list(accumulate([0] + A)) -    ans = 0 -    for i in range(N - 1): -        ans += A[i] * (S[N] - S[i + 1]) -        ans %= MOD +    ans = (sum(A) ** 2) % MOD - (sum(pow(a, 2, MOD) for a in A)) % MOD +    ans *= pow(2, MOD - 2, MOD) +    ans %= MOD