#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
using namespace std;
int main() {
// your code goes here
long long int i,n,onee=0;
scanf("%I64d",&n); //printf("%I64d\n",n);
long long int a[n];
vector<long long int> temp;
vector<pair<long long int,long long int>> pos;
for(i=0;i<n;i++) {
scanf("%I64d",&a[i]);
//printf("%I64d ",a[i]);
}
for(i=0;i<n;i++) {
//if found a pair
if(temp.size()>0 && find(temp.begin(),temp.end(),a[i])!=temp.end()) {
pos.push_back(make_pair(onee,i));
temp.clear();
onee=i+1;
}
else {
temp.push_back(a[i]);
}
//printf("%ld\n",onee);
}
if(onee == 0) printf("-1\n");
else if(onee != n) pos[pos.size()-1].second = n-1;
if(pos.size()>0) {
printf("%d\n",pos.size());
for(i=0;i<pos.size();i++) printf("%I64d %I64d\n",pos[i].first+1,pos[i].second+1);
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxjc3RyaW5nPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8cXVldWU+CiNpbmNsdWRlIDxjc3RkbGliPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUJCiAgICBsb25nIGxvbmcgaW50IGksbixvbmVlPTA7CiAgICBzY2FuZigiJUk2NGQiLCZuKTsgLy9wcmludGYoIiVJNjRkXG4iLG4pOwogICAgbG9uZyBsb25nIGludCBhW25dOwogICAgdmVjdG9yPGxvbmcgbG9uZyBpbnQ+IHRlbXA7CiAgICB2ZWN0b3I8cGFpcjxsb25nIGxvbmcgaW50LGxvbmcgbG9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