#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  queue<ii> segs;
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  set<int> s;
  int start = 1;
  for (int i = 0; i < n; i++) {
    if (s.find(A[i]) != s.end()) {
      segs.push(ii(start, i + 1));
      s.clear();
      start = i + 2;
    } else {
      s.insert(A[i]);
    }
  }
  if (segs.size() == 0)
    cout << "-1" << endl;
  else
    cout << segs.size() << endl;
  while (!segs.empty()) {
    ii seg = segs.front();
    segs.pop();
    if (segs.empty())
      cout << seg.first << " " << n << endl;
    else
      cout << seg.first << " " << seg.second << endl;
  }
  return 0;
}
