from itertools import accumulate





def main():

    n = int(eval(input()))

    array = [int(x) for x in input().split()]

    acc = accumulate(array)

    mod = 10 ** 9 + 7

    ans = 0

    for i, ai in enumerate(acc):

        if i == n - 1:

            continue

        ans += ai * array[i + 1]

        ans %= mod

    return ans





if __name__ == '__main__':

    print((main()))

def main():

    eval(input())  # n

    array = [int(x) for x in input().split()]

    mod = 10 ** 9 + 7

    total = 0

    center_blocks = 0

    for x in array:

        total += x

        center_blocks += x ** 2

    total = total ** 2

    return (total - center_blocks) // 2 % mod





if __name__ == '__main__':

    print((main()))

from itertools import accumulate


def main():
    n = int(eval(input()))
    array = [int(x) for x in input().split()]
    acc = accumulate(array)
    mod = 10**9 + 7
    ans = 0
    for i, ai in enumerate(acc):
        if i == n - 1:
            continue
        ans += ai * array[i + 1]
        ans %= mod
    return ans


if __name__ == "__main__":
    print((main()))

def main():
    eval(input())  # n
    array = [int(x) for x in input().split()]
    mod = 10**9 + 7
    total = 0
    center_blocks = 0
    for x in array:
        total += x
        center_blocks += x**2
    total = total**2
    return (total - center_blocks) // 2 % mod


if __name__ == "__main__":
    print((main()))

-from itertools import accumulate - - -    n = int(eval(input())) +    eval(input())  # n -    acc = accumulate(array) -    ans = 0 -    for i, ai in enumerate(acc): -        if i == n - 1: -            continue -        ans += ai * array[i + 1] -        ans %= mod -    return ans +    total = 0 +    center_blocks = 0 +    for x in array: +        total += x +        center_blocks += x**2 +    total = total**2 +    return (total - center_blocks) // 2 % mod