#include <bits/stdc++.h>
using namespace std;
int main() {
  int fruits_n, select_n;
  cin >> fruits_n >> select_n;
  int fruit[fruits_n];
  for (int i = 0; i < fruits_n; i++) cin >> fruit[i];
  sort(fruit, fruit + fruits_n);
  int min = 0;
  for (int i = 0; i < 3; i++) min += fruit[i];
  cout << min << endl;
}
