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 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define LINE_BUF_SIZE 256

void merge_sort(int *A, int left, int right, int *tmp){

    if(right - left > 1){   /*最小のサブリストであるかどうか*/
        
        int i,j,k,half = (right+left)/2;

        merge_sort(A,left,half,tmp);    /*右のブロック*/
        merge_sort(A,half,right,tmp);   /*左のブロック*/

        for(i=left;i<right;i++){
            tmp[i]=A[i];
        }
        
        for(i = left,j = left,k = half;i<right;i++){
            if(k == right){
                A[i] = tmp[j];
                j++;
            }
            else if(tmp[j] <= tmp[k] && j < half){
                A[i] = tmp[j];
                j++;
            }
            else{
                A[i] = tmp[k];
                k++;
            }
        }

    }

}

void pre_merge_sort(int *A, int N){
    int *tmp = (int *)malloc(sizeof(int)*N);
    merge_sort(A,0,N,tmp);
    free(tmp);
}

int main(){

    int i,j,k;
    int N;
    char line[LINE_BUF_SIZE];

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d", &N);

    int *a = malloc(sizeof(int)*(N+1));
    int *a_hold = malloc(sizeof(int)*(N+1));

    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
        a_hold[i] = a[i];
    }

    pre_merge_sort(a,N);

    int max;
    int j_hold;

    max = a[N-1];
    int judge = 0;
    i = 0;

    while(judge == 0){
            for(j=N-1;j>0;j--){
                if(max/2+i == a[j]){
                    j_hold = j;
                    judge = 1;
                    break;
                } 
            }
        i++;
    }

    printf("%d\n",max);
    printf("%d",a[j_hold]);

    return 0;

}