import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

object Solve {

  private val br = BufferedReader(InputStreamReader(System.`in`))
  private val out = PrintWriter(System.out)

  fun solve() {

    val MOD: Long = 1_000_000_007L

    val n = br.readLine()!!.toInt()
    val a = br.readLine()!!.split(' ').map { it.toLong() }

    var back = mutableListOf(0L)

    var sum = 0L

    for (i in n - 1 downTo 0) {
      sum += a[i]
      sum %= MOD
      back.add(sum)
    }

    var ans = 0L

    for (i in 1 until n) {
      ans += (a[i - 1] * back[n - i]) % MOD
      ans %= MOD
    }

    out.println(ans % MOD)
    out.flush()
  }
}

fun main(args: Array<String>) {
  Solve.solve()
}