#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = (0); i < (n); ++i) cin >> p[i];
  sort(p.begin(), p.end());
  cout << p[0] + p[1] + p[2] << endl;
  return 0;
}
