#include <iostream>
#include <algorithm>
using namespace std;

int main(void){
    int N,K;
    cin >> N >> K;
    int l[N];
    for(int i = 0; i < N ;i++){
        cin >> l[i];
    }
    sort(l ,l+N ,greater<int>());
    int answer = 0;
    for(int i = 0; i < K ; i++){
        answer += l[i];
    }
    cout << answer << endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e3 + 5;

int n, k, ans;

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    for(int tc = 1; tc <= T; tc++) {
        cin >> n >> k;
        ans = 1;
        while(n--) ans = min(ans * 2, ans + k);
        cout << ans << "\n";
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    
}