#include <bits/stdc++.h>
int main(void) {
  long int n, k, p[1000], i = 0, s = 0, min = 0, tmp = 0, j = 0;
  scanf("%ld%ld", &n, &k);
  for (i = 0; i < n; i++) scanf("%ld", &p[i]);
  while ((j < n) && (j < 3)) {
    min = p[j];
    for (i = j; i < n; i++) {
      if (min > p[i]) {
        tmp = min;
        min = p[i];
        p[i] = tmp;
      }
    }
    s += min;
    j++;
  }
  printf("%ld\n", s);
  return 0;
}
