#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> S;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    S.push_back(a);
  }
  sort(S.begin(), S.end());
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    ans += S[i];
  }
  cout << ans << endl;
  return 0;
}
