// legmessz ross sorrendu.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
struct adat
{
int ertek, index;
};
bool hasonlit(adat a, adat b)
{
if (a.ertek == b.ertek)
{
if (a.index > b.index) return 1;
else return 0;
}
else if (a.ertek > b.ertek) return 1;
else return 0;
}
int k=0,v=0,tav;
adat maxi;
int main()
{
int n;
cin >> n;
vector<adat>x(n + 1);
for (int i = 1; i <= n; ++i)
{
cin >> x[i].ertek;
x[i].index = i;
}
sort(x.begin()+1, x.end(), hasonlit);
maxi.ertek=x[1].ertek;
maxi.index = x[1].index;
for (int i = 2; i <= n - 1; ++i)
{
if (maxi.index < x[i].index)
{
if (x[i].index - maxi.index > tav)
{
tav = x[i].index - maxi.index;
k = maxi.index;
v = x[i].index;
}
else if (x[i].index - maxi.index == tav && maxi.index<k)
{
k = maxi.index;
v = x[i].index;
}
}
else if (maxi.index > x[i].index)
{
maxi.ertek = x[i].ertek;
maxi.index = x[i].index;
}
}
if (k && v) cout << k << " " << v;
else cout << -1;
return 0;
}
/*
10
1 2 3 4 5 6 7 8 9 10
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file