Amr has got a large array of size *n*. Amr doesn't like large arrays so he intends to make it smaller.

Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number occurs in this array. He wants to choose the smallest subsegment of this array such that the beauty of it will be the same as the original array.

Help Amr by choosing the smallest subsegment possible.
The first line contains one number *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>), the size of the array.

The second line contains *n* integers *a*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>), representing elements of the array.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class LargeArray {
	static void solve() {
		// Counter c = new Counter();
		// while(true){
		// String op = next();
		// int n = nextInt();
		//
		// if(op.equals("a"))
		// c.add(n);
		// else if (op.equals("m")){
		// System.out.println(c.getMostCommonCount());
		// }
		// else if (op.equals("d"))
		// c.removeOne(n);
		//
		// System.out.println(c);
		// }

		int n = nextInt();
		int[] a = nextIntArr(n);

		Counter d = new Counter();
		for (int i : a)
			d.add(i);
		int b = d.getMostCommonCount();

		Counter c = new Counter();
		int[] res = new int[]{0, n - 1};
		int r = 0;
		c.add(a[0]);
		for (int l = 0; l < n; l++) {
			while (r < n - 1 && c.getMostCommonCount() < b) {
				r++;
				c.add(a[r]);
			}

//			System.err.println(l + " " + r);
			
			if (c.getMostCommonCount() >= b && r - l < res[1] - res[0])
				res = new int[] { l, r };
			
			c.removeOne(a[l]);
		}
		
		writer.println((res[0] + 1) + " " + (res[1] + 1));
	}

	static class Counter {
		Map<Integer, Integer> count = new HashMap<>();
		TreeMap<Integer, HashSet<Integer>> mostCommon = new TreeMap<>();

		void add(int i) {
			count.merge(i, 1, Integer::sum);

			int cur_cnt = cnt(i);
			if (!mostCommon.containsKey(cur_cnt))
				mostCommon.put(cur_cnt, new HashSet<>());
			mostCommon.get(cur_cnt).add(i);

			cur_cnt--;
			if (cur_cnt > 0) {
				mostCommon.get(cur_cnt).remove(i);
				if (mostCommon.get(cur_cnt).isEmpty())
					mostCommon.remove(cur_cnt);
			}
		}

		void removeOne(int i) {
			int cur_cnt = cnt(i);
			mostCommon.get(cur_cnt).remove(i);

			if (mostCommon.get(cur_cnt).isEmpty())
				mostCommon.remove(cur_cnt);

			cur_cnt--;
			if (cur_cnt >= 0) {
				if (!mostCommon.containsKey(cur_cnt))
					mostCommon.put(cur_cnt, new HashSet<>());
				mostCommon.get(cur_cnt).add(i);
			}

			count.put(i, count.get(i) - 1);
			if (count.get(i) == 0)
				count.remove(i);
		}

		int cnt(int i) {
			return count.getOrDefault(i, 0);
		}

		int getMostCommonCount() {
			return mostCommon.lastKey();
		}

		@Override
		public String toString() {
			return "[ " + count.toString() + " | " + mostCommon.toString() + " ]";
		}
	}

	public static void main(String[] args) {
		solve();
		writer.close();
	}

	static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer tokenizer = new StringTokenizer("");
	static PrintWriter writer = new PrintWriter(System.out);

	static String next() {
		while (!tokenizer.hasMoreTokens())
			try {
				tokenizer = new StringTokenizer(bf.readLine());
			} catch (Exception e) {
				return null;
			}
		return tokenizer.nextToken();
	}

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

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

	static double nextDouble() {
		return Double.parseDouble(next());
	}

	static int[] nextIntArr(int n) {
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = nextInt();
		}

		return a;
	}

}
