#include <iostream>
#include<fstream>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int v[1000000], n;
void citire(int n, int v[])
{
for (int i = 0; i < n; ++i)
{
fin >> v[i];
}
}
void majoritar(int n, int v[])
{
int major, contor = 1;
major = v[0];
for (int i = 1; i < n; ++i)
{
if (v[i] == major)
{
contor++;
}
else
contor--;
if (contor == 0){
major = v[i];
contor = 1;
}
}
contor = 0;
for (int i = 0; i < n; ++i)
{
if (v[i] == major)
contor++;
}
if (contor > n / 2)
fout << major << ' ' << contor;
else
fout << -1;
}
int main()
{
fin >> n;
citire(n, v);
majoritar(n, v);
return 0;
}