#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, pair<int, int> > good;
  int n;
  scanf("%d", &n);
  int a[300004];
  int l[300005];
  int r[300005];
  int k = 0;
  l[k] = 0;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    pair<int, int> element;
    element = good[a[i]];
    if (element.first == 0) {
      good[a[i]].first = 1;
      good[a[i]].second = i;
      continue;
    }
    if (element.first == 1) {
      if (k == 0 || r[k - 1] < element.second) {
        l[k + 1] = i + 1;
        r[k] = i;
        k++;
        good[a[i]].first = 0;
        good[a[i]].second = 0;
      } else if (k > 0 && r[k - 1] > element.second) {
        good[a[i]].first = 1;
        good[a[i]].second = i;
      }
    }
  }
  if (k == 0) {
    printf("-1\n");
    return 0;
  }
  if (r[k - 1] < n - 1) r[k - 1] = n - 1;
  printf("%d\n", k);
  for (int i = 0; i < k; i++) {
    printf("%d %d\n", l[i] + 1, r[i] + 1);
  }
  return 0;
}
