#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n;
  cin >> k;
  int *arr = new int[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n, greater<int>());
  int sum = 0;
  for (int i = 0; i < 3; i++) sum += arr[i];
  cout << sum;
  return 0;
}
