
Imports System.Console
Module Module1
    Dim w As Int64
    Dim ii, iii As Int64
    Dim ans As Int64
    Dim md As Int64 = (10 ^ 9) + 7
    Dim max, min As Int64
    Dim n, k, x, t, d As Int64
    Sub Main()
        n = ReadLine()
        Dim s() As String = ReadLine().Split
        Dim a(n) As Integer
        For i = 1 To n
            a(i) = s(i - 1)
        Next
        Dim asum As Int64
        For i = 1 To n
            asum += a(i)
            asum = asum Mod md
        Next
        w = asum
        For i = 1 To n - 1
            'w = 0
            'For ii = i + 1 To n
            '    w += a(ii)
            '    w = w Mod md
            'Next
            w -= a(i)
            If w < 0 Then
                w += md
            End If
            ans += (w * a(i)) Mod md
            'ii = 0
            'Dim ww As Int64 = a(i) * (10 ^ 2)
            'Dim www As Int64
            'For ii = 1 To w \ (10 ^ 2)
            '    www += ww
            '    www = www Mod md
            'Next
            'www += (a(i) * (w Mod (10 ^ 2)))
            'www = www Mod md
            'ans += www
            ans = ans Mod md
        Next
        WriteLine(ans)
        ReadLine()
    End Sub
    Sub Add(ByRef arr() As Integer, ByVal num As Integer)
        If arr Is Nothing Then
            ReDim arr(0)
            arr(0) = num
        Else
            ReDim Preserve arr(arr.Length)
            arr(arr.Length - 1) = num
        End If
    End Sub
End Module
