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