#include <stdio.h>
#include <ctype.h>
// Program de Mircea Rebengiuc
// inceput pe 2021.11.12
#define MAXN 1000000
#define MAXBUF (128 * 1024)
int v[MAXN];
FILE *fin, *fout;
char ibuf[MAXBUF];
int ibp = MAXBUF - 1;
static inline int bgetc(){
if( (ibp = ((ibp + 1) & (MAXBUF - 1))) == 0 )
fread(ibuf, sizeof(char), MAXBUF, fin);
return ibuf[ibp];
}
static inline int fgetint(){
int n = 0, ch;
while( !isdigit(ch = bgetc()) );
do
n = n * 10 + ch - '0';
while( isdigit(ch = bgetc()) );
return n;
}
int main(){
fin = fopen("elmaj.in", "r");
fout = fopen("elmaj.out", "w");
int n, i, delta = 0, cand = 0;
n = fgetint();
for( i = 0 ; i < n ; i++ ){
v[i] = fgetint();
if( delta == 0 ){
cand = v[i];
delta = 1;
}else if( v[i] == cand )
delta++;
else
delta--;
}
delta = 0;
for( i = 0 ; i < n ; i++ )
delta += (cand == v[i]);
if( delta * 2 > n )
fprintf(fout, "%d %d\n", cand, delta);
else
fprintf(fout, "-1\n");
fclose(fin);
fclose(fout);
return 0;
}