#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int PatrollingTheMojaveAlmostMakesYouWishForANuclearWinter,ok;
	long long SUM=0;
	cin>>PatrollingTheMojaveAlmostMakesYouWishForANuclearWinter>>ok;
	int NCRtrooper[PatrollingTheMojaveAlmostMakesYouWishForANuclearWinter];
	for(int i=0;i<PatrollingTheMojaveAlmostMakesYouWishForANuclearWinter;i++){
		cin>>NCRtrooper[i];
			SUM+=(PatrollingTheMojaveAlmostMakesYouWishForANuclearWinter*(i+1)-i*(i+1))*NCRtrooper[i];
			SUM%=1000000007;
	}
	cout<<SUM;
	return 0;
}