#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int& x : a) cin >> x;
  vector<int> d(n + 1, -1);
  vector<int> p(n + 1, -1);
  map<int, int> pr;
  for (int i = 0; i < n; ++i) {
    int val = a[i];
    auto it = pr.find(val);
    d[i + 1] = d[i];
    p[i + 1] = p[i];
    if (it != pr.end()) {
      int nd = 1 + d[it->second];
      if (d[i + 1] < nd) {
        d[i + 1] = nd;
        p[i + 1] = it->second;
      }
      it->second = i;
    } else {
      pr[val] = i;
    }
  }
  if (d[n] < 0) {
    cout << (-1) << '\n';
    exit(0);
  };
  vector<pair<int, int> > res;
  int cur = n;
  while (cur > 0) {
    if (p[cur] < 0) {
      res.back().first = 1;
      break;
    }
    res.push_back({p[cur] + 1, cur});
    cur = p[cur];
  }
  cout << res.size() << '\n';
  for (const auto& r : res) cout << r.first << ' ' << r.second << '\n';
}
