#include <iostream>
#include <vector>

using namespace std;


int main()
{
    unsigned long long int n;
    unsigned long long int k;
    cin >> n >> k;
    unsigned long long int A[n+1];

    unsigned long long int suma = 0;

    for(long long int i=1; i <= n; i++)
    {
        cin >> A[i];
        suma += A[i];
        suma %= 1000000007;
    }

    if(k==0)
    {
        cout << suma << "\n";
        return 0;
    }
    if(k==1)
    {
      suma = 0;
      for(long long int i=1; i <= n; i++)
      {
         suma += A[i] * i * (n-i+1);
         suma %= 1000000007;
      }
      cout << suma << "\n";
    }

    return 0;
}