#include <iostream>
#include <vector>

using namespace std;

unsigned long long int zbir(vector<unsigned long long int> v, unsigned long long int k)
{
    unsigned long long int N = v.size(), a = 0;
    for(unsigned long long int i = k; i < N; i++)
        a+= v[i];
    return a;
}
int main()
{
    int k;
    unsigned long long int a, N, z = 0;
    vector<unsigned long long int> v;

    cin >> N >> k;
    for(unsigned long long int i = 0; i < N; i++)
    {
        cin >> a;
        v.push_back(a);
    }
    if(k == 0)
    {
        cout << zbir(v, 0) << endl;
    }
    if(k == 1)
    {
        a = 0;
        for(unsigned long long int i = 0; i < N; i++)
        {
            for(unsigned long long int p = i; p < N; p++)
            {
                z+= v[p];
            }
        }
        cout << z << endl;
    }

    return 0;
}