#include <bits/stdc++.h>
int main() {
  int n, h(0);
  int a[300000];
  std::set<int> s;
  std::vector<std::array<int, 2>> r;
  std::scanf("%d", &n);
  for (int i(0); i < n; ++i) std::scanf("%d", a + i);
  for (int i(0); i < n; ++i) {
    if (s.find(a[i]) != s.end()) {
      s.clear();
      r.push_back({{h, i}});
      h = i + 1;
    } else {
      s.insert(a[i]);
    }
  }
  if (r.empty()) {
    std::puts("-1");
  } else {
    if (r.back()[1] < n - 1) r.back()[1] = n - 1;
    std::printf("%ld\n", r.size());
    for (auto e : r) std::printf("%d %d\n", e[0] + 1, e[1] + 1);
  }
  return 0;
}
