import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
int arrayLength = in.nextInt();
int[] array = new int[arrayLength];
for(int i = 0; i < arrayLength; i++) {
array[i] = in.nextInt();
}
int currentMaxLength = 1;
int currentStartIndex = 0;
Set<Integer> valueSet =new HashSet<>();
List<Integer> startIndexList = new ArrayList<>();
startIndexList.add(0);
valueSet.add(array[0]);
int i = 1;
while (true) {
if (i == array.length) {
break;
}
if (valueSet.contains(array[i])) {
int preValue = array[currentStartIndex];
valueSet.remove(preValue);
currentStartIndex++;
} else {
valueSet.add(array[i]);
int curentLength = i - currentStartIndex + 1;
if (curentLength > currentMaxLength) {
currentMaxLength = curentLength;
startIndexList.clear();
startIndexList.add(currentStartIndex);
} else if (curentLength == currentMaxLength){
startIndexList.add(currentStartIndex);
}
i++;
}
}
System.out.println(startIndexList.size());
for(int startIndex : startIndexList) {
int printStartIndex = startIndex + 1;
int printEndIndex = startIndex + currentMaxLength;
System.out.println(printStartIndex + " " + printEndIndex);
}
}
}