#include <fstream>
#include <vector>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int main() {
int n;
fin >> n;
vector<int> v(n);
int candidat = -1, voturi = 0;
for (int i = 0; i < n; i++) {
fin >> v[i];
if (voturi == 0) {
candidat = v[i];
voturi = 1;
} else if (v[i] == candidat) {
voturi++;
} else {
voturi--;
}
}
int aparitii = 0;
for (int i = 0; i < n; i++) {
if (v[i] == candidat) {
aparitii++;
}
}
if (aparitii >= n / 2 + 1) {
fout << candidat << " " << aparitii;
} else {
fout << -1;
}
return 0;
}