import java.util.*
fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)

    var result = 0L
    val maxMod = 1000000007L
    val N = reader.nextInt()
    val nums = mutableListOf<Long>()
    repeat(N){
        nums.add(reader.nextLong())
    }

    var initSum : Long = 0L
    initSum += nums[nums.size - 1]

    for(index in nums.size - 2 downTo  0){
       result = (result + initSum * nums[index]).rem(maxMod)
        initSum += nums[index]
        initSum = initSum.rem(maxMod)
    }
    println(result)
}