5
5 3
2 4
3 1
4 5
 4
2 4
3 2
2 1
 5
5 3
2 4
3 1
4 5
 2
1 2
 4
3 4
2 3
3 1
 10
8 10
2 9
7 8
4 1
7 3
4 7
2 5
2 4
4 6
 5
3 4
3 2
3 1
1 5
 3
1 2
2 3
 5
1 2
1 3
1 4
1 5

1 2
2 3
2 4
 1 3
2 4
3 5
4 5
 1 2
 1 3
2 3
3 4
 1 4
2 4
2 5
2 9
3 7
4 6
4 7
7 8
8 10
 1 3
1 5
2 3
3 4
 1 2
2 3
 1 2
1 3
1 4
1 5

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Try2{
	static final int Mod = 100_000_0007;
	public static void main(String[] args) throws IOException {
		FastScanner fs = new FastScanner();
//		int t= fs.nextInt();
		int t =1;
		while(t-->0) {
			
			int n = fs.nextInt();
			
			
			System.out.println("? " + n);
			System.out.flush();
			
			
			ArrayList<int[]> ans = new ArrayList<int[]>();
			
			
			for(int i=0 ;i<n;i++) {
				ans.add(new int[] {fs.nextInt()-1, i});
			}
			
			Collections.sort(ans,(x,y)->x[0]-y[0]);
			
			
			ArrayList<int[]> may = new ArrayList<int[]>();
			
			int ini = ans.get(0)[1]+1;
			for(int i=1;i<n;i++) {
				
				
				may.add(new int[] {ini,ans.get(i)[1]+1});
				while(i!=n-1&&ans.get(i)[0]==ans.get(i+1)[0]) {
					may.add(new int[]{ini,ans.get(i+1)[1]+1});
					i++;
				}
				
				ini = ans.get(i)[1]+1;
			}
			System.out.println("!");
			for(int i =0;i<n-1;i++) {
				System.out.println(may.get(i)[0] + " " + may.get(i)[1]);
				System.out.flush();
			}
			
			System.out.flush();
			
		}
	}
	
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}
