#include <bits/stdc++.h>
using namespace std;
void solve(const vector<int>& pearl) {
  vector<pair<int, int>> ans;
  ans.reserve(pearl.size());
  set<int> app;
  int l = 0;
  for (int i = 0; i < pearl.size(); i++) {
    int cur = pearl[i];
    if (app.find(cur) != end(app)) {
      ans.push_back(make_pair(l + 1, i + 1));
      l = i + 1;
      set<int>().swap(app);
    } else
      app.insert(cur);
  }
  if (l != pearl.size()) {
    if (l == 0) {
      printf("-1\n");
      return;
    }
    ans[ans.size() - 1].second = pearl.size();
  }
  printf("%d\n", ans.size());
  for (const auto& a : ans) printf("%d %d\n", a.first, a.second);
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> pearl(n);
  for (int i = 0; i < n; i++) scanf("%d", &pearl[i]);
  solve(pearl);
}
