#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int> > ans;
  set<int> acc;
  int a;
  int cnt = 0;
  int last = 1;
  bool exist = false;
  bool badlast = false;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (acc.find(a) != acc.end()) {
      ++cnt;
      acc.clear();
      ans.push_back(make_pair(last, i + 1));
      last = i + 2;
      exist = true;
      badlast = false;
    } else {
      acc.insert(a);
      badlast = true;
    }
  }
  if (!exist) {
    cout << -1 << "\n";
  } else {
    if (badlast) {
      ans[ans.size() - 1].second = n;
    }
    cout << cnt << "\n";
    for (int i = 0; i < ans.size(); ++i) {
      cout << ans[i].first << " " << ans[i].second << "\n";
    }
  }
}
