#include <bits/stdc++.h>
int main() {
  int n, k, p[999], tmp, ans;
  char input[256];
  fgets(input, 256, stdin);
  sscanf(input, "%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    sscanf(input, "%d", &p[i]);
    for (int j = i + 1; j < n; n++) {
      if (p[i] > p[j]) {
        tmp = p[i];
        p[i] = p[j];
        p[j] = tmp;
      }
    }
  }
  for (int i = 0; i < k; i++) {
    ans += ans + p[i];
  }
  printf("%d", ans);
}
