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()))

def main():

    eval(input())

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

    mod = 10 ** 9 + 7

    ans = 0

    multiplier = 0

    for x in array:

        ans = (ans + x * multiplier) % mod

        multiplier = (multiplier + x) % 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()))

def main():
    eval(input())
    array = (int(x) for x in input().split())
    mod = 10**9 + 7
    ans = 0
    multiplier = 0
    for x in array:
        ans = (ans + x * multiplier) % mod
        multiplier = (multiplier + x) % mod
    return ans


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

-    eval(input())  # n -    array = [int(x) for x in input().split()] +    eval(input()) +    array = (int(x) for x in input().split()) -    total = 0 -    center_blocks = 0 +    ans = 0 +    multiplier = 0 -        total += x -        center_blocks += x**2 -    total = total**2 -    return (total - center_blocks) // 2 % mod +        ans = (ans + x * multiplier) % mod +        multiplier = (multiplier + x) % mod +    return ans