#include <bits/stdc++.h>
using namespace std;
map<pair<long long int, long long int>, long long int> mp;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > ans;
  long long int a[n + 1];
  long long int seg = 1;
  long long int st = 1;
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
    mp[{a[i], seg}]++;
    if (mp[{a[i], seg}] == 2) {
      ans.push_back({st, i});
      seg++;
      st = i + 1;
    }
  }
  if (ans.size() > 0) {
    ans[(long long int)ans.size() - 1].second = n;
    cout << ans.size() << "\n";
    for (auto it : ans) cout << it.first << " " << it.second << "\n";
  } else
    cout << -1;
}
