#include <bits/stdc++.h>
int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> p(n);
  for (auto &pp : p) {
    std::cin >> pp;
  }
  std::sort(std::begin(p), std::end(p));
  std::cout << (p[0] + p[1] + p[2]) << std::endl;
}
