Problem:
Score : 400 points

Problem Statement

Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.
From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized.
If there are multiple pairs that maximize the value, any of them is accepted.

Constraints

2 \leq n \leq 10^5

0 \leq a_i \leq 10^9

a_1,a_2,...,a_n are pairwise distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_n

Output

Print a_i and a_j that you selected, with a space in between.

Sample Input 1

5
6 9 4 2 11

Sample Output 1

11 6

\rm{comb}(a_i,a_j) for each possible selection is as follows:

\rm{comb}(4,2)=6

\rm{comb}(6,2)=15

\rm{comb}(6,4)=15

\rm{comb}(9,2)=36

\rm{comb}(9,4)=126

\rm{comb}(9,6)=84

\rm{comb}(11,2)=55

\rm{comb}(11,4)=330

\rm{comb}(11,6)=462

\rm{comb}(11,9)=55

Thus, we should print 11 and 6.

Sample Input 2

2
100 0

Sample Output 2

100 0

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include "algorithm"
#include "array"
#include "cmath"
#include "complex"
#include "cstdio"
#include "deque"
#include "initializer_list"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "regex"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "vector"
#define FOR(i, n) for ((i) = 0; (i) < (n); ++(i))
#define in_int(x) scanf(" %d/n", &(x));
#define in_str(x) scanf(" %[a-zA-Z (+-0-9_) #.]/n", (x));
#define ch(x) printf("debug %d\n", (x))

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
int dx_ar[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy_ar[] = {1, 0, -1, 1, -1, 1, 0, -1};

template <typename type> void print_vector(type d1_arr);
template <typename type> void print_2darray(type d2_arr);
std::vector<std::vector<int>> padding(std::vector<std::vector<int>> arr,
                                      int pad);
inline std::vector<int> str_int_split(char *s);
inline std::vector<std::vector<int>> in_d2_arr(int N, int size = 1000);
inline std::vector<int> in_d1_arr(int size = 1000);
inline double d2_distance(int x1, int y1, int x2, int y2);
inline int d2_manhattan(int x1, int y1, int x2, int y2);

int main() {
  int N;
  in_int(N);
  auto v = in_d1_arr();
  if (v.size() == 2) {
    std::sort(v.begin(), v.end());
    printf("%d %d\n", v.back(), v.front());
  } else {
    std::sort(v.begin(), v.end());
    int n = v.back();
    int r = int(n / 2);
    auto itr = std::lower_bound(v.begin(), v.end(), r);
    int kouho1 = *itr;
    int kouho2 = *(itr - 1);
    int kouho;
    if (abs(n - kouho1) > abs(n - kouho2)) {
      kouho = kouho2;
    } else {
      kouho = kouho1;
    }
    printf("%d %d\n", n, kouho);
  }
}

template <typename type> void print_vector(type d1_arr) {
  for (auto seg : d1_arr) {
    std::cout << seg;
    std::cout << " ";
  }
  std::cout << std::endl;
}

template <typename type> void print_2dvector(type d2_arr) {
  for (auto seg1 : d2_arr) {
    for (auto seg2 : seg1) {
      std::cout << seg2;
      std::cout << " ";
    }
    std::cout << std::endl;
  }
}

template <typename type> void print_map(type map) {
  for (auto m : map) {
    std::cout << m.first;
    std::cout << ":";
    std::cout << m.second;
    std::cout << " ";
  }
  std::cout << std::endl;
}

std::vector<std::vector<int>> padding(std::vector<std::vector<int>> arr,
                                      int pad) {
  std::vector<std::vector<int>> arr_c = arr;
  int height = arr_c.size();
  int width = arr_c[0].size();
  std::vector<int> v;
  v.resize(width);
  fill(v.begin(), v.end(), pad);
  arr_c.insert(arr_c.begin(), v);
  arr_c.push_back(v);
  int i;
  FOR(i, height + 2) {
    arr_c[i].insert(arr_c[i].begin(), pad);
    arr_c[i].resize(width + 2);
  }
  arr_c.shrink_to_fit();
  return arr_c;
}

inline std::vector<int> str_int_split(char *s) {
  char *tok = strtok(s, " ,");
  std::vector<int> v;
  while (tok != NULL) {
    v.push_back(atoi(tok));
    tok = strtok(NULL, " ,"); /* 2回目以降 */
  }
  return v;
}

inline std::vector<std::vector<int>> in_d2_arr(int N, int size) {
  int i;
  std::vector<std::vector<int>> v;
  FOR(i, N) {
    char *lines;
    lines = new char[size];
    in_str(lines);
    v.push_back(str_int_split(lines));
    delete[] lines;
  }
  return v;
}

inline std::vector<int> in_d1_arr(int size) {
  std::vector<int> v;
  char *lines;
  lines = new char[size];
  in_str(lines);
  v = str_int_split(lines);
  delete[] lines;
  return v;
}

inline double d2_distance(int x1, int y1, int x2, int y2) {
  return sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2));
}

inline int d2_manhattan(int x1, int y1, int x2, int y2) {
  return (abs(x2 - x1) + abs(y2 - y1));
}