#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll t[100001];
int main() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
ll k, n, sum = 0;
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> t[i];
sort(t, t + n);
for (int i = 1; i <= n; i++)
{
if (i <= k)
sum +=t[i];
}
cout << sum - 1 <<"\n";
return 0;
}