#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  map<int, int> M;
  int start = 0, end = 0;
  vector<pair<int, int>> ans;
  while (end < n) {
    int val = arr[end];
    if (M[val] == 1) {
      ans.push_back(make_pair(start + 1, end + 1));
      M.clear();
      start = end + 1;
    } else {
      M[val] = 1;
    }
    end++;
  }
  if (ans.size() == 0)
    cout << "-1";
  else {
    ans.back().second = n;
    cout << ans.size() << endl;
    for (auto x : ans) cout << x.first << " " << x.second << endl;
  }
}
