#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip> 
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int zbir = 0;
    if (k == 1) {
        for (int i = 0; i < n; i++) {
            zbir += a[i] * (n - i) * (i + 1);
        }
    }
    else if (k == 0) {
        for (int i = 0; i < n; i++) {
            zbir += a[i];
        }
    }
   
    cout << zbir;
        

}