#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << endl;
#define task ""
using namespace std;
int n;
pair <long long, int> a[100001];
int tmp, ans1, check;
long long ans2;
int main()
{
//freopen(task".inp", "r", stdin);
//freopen(task".out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i=1; i<=n; i++)
{
cin >> a[i].first;
a[i].second = i;
}
sort(a+1, a+1+n);
for (int i=1; i<=n; i++)
{
if (a[i].first != a[i-1].first)
{
tmp = a[i].second;
}
else
{
if (ans2 < a[i].second-tmp || (ans2==a[i].second-tmp && check>a[i].second))
{
ans2 = a[i].second-tmp;
ans1 = a[i].first;
check = a[i].second;
}
}
}
cout << ans1 << endl << ans2+1;
#ifdef dungctb
cerr << "Time collapse : " << fixed << setprecision(3) << 1.000*clock()/CLOCKS_PER_SEC;
#endif // dungctb
return 0;
}