#include<bits/stdc++.h>
using namespace std;

#define ll long long

ll sum,m=1000000007;
int main() {
	int n,k;
	cin >> n >> k;
	for(int i=1;i<=n;i++) {
		ll a;
		cin >> a;
		sum=(sum+((((a*i)%m)*(n+1-i))%m))%m;
	}
	cout<<sum;
}