#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename V, typename T>
bool find_num(V v, T num) {
  if (find((v).begin(), (v).end(), num) == v.end()) {
    return false;
  }
  return true;
}
int main() {
  int64_t n, k;
  cin >> n >> k;
  std::vector<int64_t> p(n);
  for (int64_t i = 0; i < n; ++i) {
    cin >> p[i];
  }
  sort((p).begin(), (p).end());
  int64_t ans = p[0] + p[1] + p[2];
  cout << ans << endl;
  return 0;
}
