#include "bits/extc++.h"

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

template<typename T>
istream &operator>>(istream &is, vector<T> &a);

template<typename T>
ostream &operator<<(ostream &os, vector<T> &a);


using ordered_set = tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    cin >> a;
    for (int i = 0; i < n; ++i) {
        a[i] += i;
    }

    std::sort(a.rbegin(), a.rend());

    ll ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += a[i];
    }
    cout << ans - k + 1 << "\n";
}

template<typename T>
istream &operator>>(istream &is, vector<T> &a) {
    for (auto &v: a) is >> v;
    return is;
}

template<typename T>
ostream &operator<<(ostream &os, vector<T> &a) {
    for (auto v: a) os << v << " ";
    return (os << "\n");
}
