#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

template<typename T>
T max2(const vector<T>& arr) {
  auto copy(arr);
  auto it = max_element(copy.begin(), copy.end());

  swap(*it, *(copy.begin()));
  it = max_element(copy.begin() + 1, copy.end());

  return copy[0] + *it;
}

int main(int argc, char* argv[]) {
  cout << max2<double>({1.0, 2.0, 3, 4, 5}) << endl;
  return 0;
}
