#!/usr/bin/env python3

import sys



MOD = 1000000007  # type: int





def solve(N: int, A: "List[int]"):

    ans = 0



    B = [sum(A[1:])]

    for i, a in enumerate(A[1:-1]):

        B.append(B[i] - a)



    for i, ai in enumerate(A[:-1]):

        ans += (ai * B[i]) % MOD

    

    print((ans % MOD))

    return





# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"

    solve(N, A)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3

import sys



MOD = 1000000007  # type: int





def solve(N: int, A: "List[int]"):

    ans = 0



    B = [sum(A[1:])]

    for i, a in enumerate(A[1:-1]):

        B.append(B[i] - a)



    for i, ai in enumerate(A[:-1]):

        ans += (ai * B[i])

    

    print((ans % MOD))

    return





# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"

    solve(N, A)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ans = 0
    B = [sum(A[1:])]
    for i, a in enumerate(A[1:-1]):
        B.append(B[i] - a)
    for i, ai in enumerate(A[:-1]):
        ans += (ai * B[i]) % MOD
    print((ans % MOD))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ans = 0
    B = [sum(A[1:])]
    for i, a in enumerate(A[1:-1]):
        B.append(B[i] - a)
    for i, ai in enumerate(A[:-1]):
        ans += ai * B[i]
    print((ans % MOD))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == "__main__":
    main()

-        ans += (ai * B[i]) % MOD +        ans += ai * B[i]