#include <bits/stdc++.h>
using namespace std;
int n, a[300005];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<pair<int, int>> ans;
  for (int i = 1; i <= n;) {
    set<int> s;
    s.insert(a[i]);
    int sz = s.size();
    int j = i + 1;
    while (j <= n) {
      s.insert(a[j]);
      if (s.size() == sz) {
        ans.push_back(make_pair(i, j));
        j++;
        break;
      } else {
        sz++;
      }
      j++;
    }
    i = j;
  }
  if (ans.size() == 0) {
    cout << -1 << endl;
  } else {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      if (i == ans.size() - 1 && ans[i].second != n) {
        cout << ans[i].first << " " << n << endl;
        break;
      }
      cout << ans[i].first << " " << ans[i].second << endl;
    }
  }
}
