#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
using ld = long double;
/*ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);*/
mt19937 rng;
ll randInt(ll l = 1, ll r = (ll)1e18) {
    return uniform_int_distribution<ll>(l, r)(rng);
}



int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (auto & i : a) cin >> i;
    ll s = n;
    for (int i = n - k; i < n; i++) {
        s += a[i];
    }
    cout << s;

    return 0;
}
