#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL 
#include "/media/brayand/BrayanD/debugger.h"
#else
#define db(...) false
#define dbl(...) false
#define dbg(...) false
#define dbm(...) false
#define dbs(...) false
#define dbas(...) false
#endif

bool query(int a, int b)
{
	cout << "?" << " " << a << " " << b << '\n';
	cout.flush();
	string qu;
	cin >> qu;

	if(qu == "Yes")return true;
	return false;
}

void answer(int a, int b)
{
	cout << "!" << " " << a << " " << b << '\n';
	cout.flush();
}

int32_t main()
{
	int N;
	cin >> N;

	vector<pair<int,int>> vect;

	vector<int> arr(N+1);

	for(int i = 1 ; i <= N ; i++)
	{
		int n;
		cin >> n;
		arr[i] = n;
		vect.push_back({n,i});
	}

	sort(vect.begin(), vect.end());

	int sum = 0;
	int tam = 0;

	vector<vector<pair<int,int>>> vvv;

	vector<pair<int,int>> temp;

	for(int i = 0 ; i < N ; i++)
	{
		sum += vect[i].first;
		tam++;
		temp.push_back(vect[i]);

		if(tam)
		{
			if(sum == tam*(tam-1)/2)
			{
				vvv.push_back(temp);
				for(int j = i+1 ; j < N ; j++)
				{
					vect[j].first-=tam;
				}
				temp.clear();
				sum = 0;
				tam = 0;
			}
		}
	}

	vector<pair<int,pair<int,int>>> qqq;

	for(int i = 0 ; i < vvv.size() ; i++)
	{
		for(int x = 0 ; x < vvv[i].size() ; x++)
		{
			for(int y = x+1 ; y < vvv[i].size() ; y++)
			{
				qqq.push_back({abs(arr[vvv[i][x].second] - arr[vvv[i][y].second]), {vvv[i][x].second, vvv[i][y].second}});
			}
		}
	}

	sort(qqq.rbegin(), qqq.rend());

        if(qqq.size())
	{
         auto x = qqq[0];
		if(query(x.second.first, x.second.second))
		{
			answer(x.second.first, x.second.second);
		}
	}

	answer(0,0);

    return 0;
}
