awk -M '\
NR==1{N=$1}
NR==2{split($0, A)}
END{
    sum = 0
    for(i=1;i<=N;i++){
        sum += A[i]
        S[i] = sum
    }
    ans = 0
    MOD = 10^9 + 7
    for(i=1;i<=N;i++){
        ans += (A[i]* (S[N]-S[i])) % MOD
    }
    print ans%MOD
}'