#include <bits/stdc++.h>
int main() {
  int n, k, i, j, l, t, ans;
  int p[1000];
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &p[i]);
  for (j = 0; j < n - 1; j++)
    for (l = j + 1; l < n; l++)
      if (p[l] < p[j]) {
        t = p[j];
        p[j] = p[l];
        p[l] = t;
      }
  ans = p[0] + p[1] + p[2];
  printf("%d", ans);
  return 0;
}
