#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n, 10000000);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  if (n == 0) {
    cout << 0 << endl;
  } else if (n == 1) {
    cout << vec.at(0) << endl;
  } else if (n == 2) {
    cout << vec.at(0) + vec.at(1) << endl;
  } else if (n >= 3) {
    cout << vec.at(0) + vec.at(1) + vec.at(2) << endl;
  }
}
