#include <bits/stdc++.h>
int main() {
  int n, k, sum = 0;
  scanf("%d%d", &n, &k);
  std::vector<int> fl(n, 0);
  for (int i = 0; i < n; i++) scanf("%d", &fl[i]);
  std::sort(fl.begin(), fl.end());
  for (int i = 0; i < 3; i++) sum += fl[i];
  printf("%d", sum);
}
