#include <bits/stdc++.h>
using namespace std;
const long long N = (long long)3e5 + 69;
long long arr[N];
set<long long> s;
vector<pair<long long, long long> > ans;
long long which[N];
long long mn[N], mx[N];
set<long long> org;
long long n;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n;
  for (long long i = 1; i < N; i++)
    which[i] = -1, mn[i] = INT_MAX, mx[i] = -INT_MAX;
  long long cur_l = 1, cur = 0;
  for (long long i = 1; i <= n; i += 1) cin >> arr[i];
  for (long long i = 1; i <= n; i += 1) {
    if (s.find(arr[i]) != s.end()) {
      cur += 1;
      which[i] = cur;
      for (long long j = cur_l; j < i; j += 1) {
        s.erase(arr[j]);
        which[j] = cur;
      }
      cur_l = i + 1;
    } else {
      s.insert(arr[i]);
    }
  }
  for (long long i = 1; i <= n; i += 1) {
    if (which[i] == -1) which[i] = cur;
  }
  for (long long i = 1; i <= n; i += 1) {
    mn[which[i]] = min(mn[which[i]], i);
    mx[which[i]] = max(mx[which[i]], i);
  }
  if (cur == 0) {
    cout << -1;
    return 0;
  }
  cout << cur << '\n';
  for (long long i = 1; i <= cur; i += 1) cout << mn[i] << ' ' << mx[i] << '\n';
}
