#include <cstdio>
const int NMAX = 1000010;
int v[NMAX];
int N;
int main () {
freopen ("elmaj.in", "r", stdin);
freopen ("elmaj.out", "w", stdout);
scanf ("%d", &N);
for (int i = 1; i <= N; i++) {
scanf ("%d", &v[i]);
}
int candidat = v[1];
int scor = 1;
for (int i = 2; i <= N; i++) {
if (v[i] == candidat) scor++;
else scor--;
if (scor <= 0) {
candidat = v[i];
scor = 1;
}
}
scor = 0;
for (int i = 1; i <= N; i++) {
if (v[i] == candidat)
scor++;
}
if (scor > N / 2) {
printf ("%d %d\n", candidat, scor);
}
else {
printf ("-1\n");
}
return 0;
}