#include <bits/stdc++.h>
using namespace std;
template <typename T>
using vv = vector<vector<T>>;
using vi = vector<long long>;
using vvi = vector<vector<long long>>;
using P = pair<long long, long long>;
using ll = long long;
constexpr ll INF = 1LL << 60;
signed main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> p(n);
  for (long long i = 0; i < (n); ++i) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  long long sum = 0;
  for (long long i = 0; i < (3); ++i) {
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}
