#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifndef DEBUG
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
#endif

using namespace __gnu_pbds;

template <typename T>
using oset = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using pll = std::pair<ll, ll>;
using ld = long double;
using i128 = __int128;

std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());

void solve(){
    ll n, k;
    std::cin >> n >> k;
    std::vector<ll> a(n);
    ll sum = n;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }
    sum += a.back();
    a.pop_back();
    --k;
    auto srt = a;
    std::sort(srt.begin(), srt.end());
    for (int i = srt.size() - 1; i >= srt.size() - k; --i) {
        sum += srt[i];
    }
    std::cout << sum;
}

int main() {
#ifdef DEBUG
    std::freopen("/home/olymp/CLionProjects/untitled/input.txt", "r", stdin);
#endif
    std::cin.tie(0) -> std::ios::sync_with_stdio(0);
    int tt = 1;
//    std::cin >> tt;
    while (tt--){
        solve();
    }
}
