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