#include <bits/stdc++.h>
using namespace std;
int n, k;
int fruits[1000];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> fruits[i];
  sort(fruits, fruits + n);
  int price = 0;
  for (int i = 0; i < 3; i++) {
    price += fruits[i];
  }
  cout << price << endl;
}
