#include <bits/stdc++.h>
using namespace std;
class QuJ {
public:
int x, y;
QuJ() {
x = 0;
y = 0;
}
};
int main() {
int n;
cin >> n;
int* a = new int [n];
int* map = new int [n + 1];
int* index = new int [n];
int length = 0;
int count = 0;
for (int i = 0; i < n; ++i)
cin >> a[i];
for (int i = 0; i < n + 1; ++i)
map[i] = 0;
int i, j;
queue <QuJ> q;
for (i = 0, j = 1, map[a[0]]++; i < n && j < n; ++j) {
map[a[j]]++;
if (map[a[j]] > 1) {
for (int k = i; k < j; ++k) {
map[a[k]]--;
if (a[k] == a[j]) {
int tl = j - i;
if (tl > length) {
length = tl;
while (!q.empty()) {
q.pop();
}
QuJ temp;
temp.x = i + 1;
temp.y = j;
q.push(temp);
count = 1;
} else if (tl == length) {
QuJ temp;
temp.x = i + 1;
temp.y = j;
q.push(temp);
count++;
}
i = k + 1;
break;
}
}
}
}
if (j - i > length) {
length = j - i;
while (!q.empty()) {
q.pop();
}
QuJ temp;
temp.x = i + 1;
temp.y = j;
q.push(temp);
count = 1;
} else if (j - i == length) {
QuJ temp;
temp.x = i + 1;
temp.y = j;
q.push(temp);
count++;
}
cout << count << endl;
while (!q.empty()) {
QuJ temp = q.front();
cout << temp.x << " " << temp.y << endl;
q.pop();
}
}
// 64 位输出请用 printf("%lld")