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