#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3 * 100 * 1000 + 10;
int arr[MAXN];
vector<int> vec;
set<int> s;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  vec.push_back(0);
  for (int i = 0; i < n; i++) {
    int y = s.size();
    s.insert(arr[i]);
    if (s.size() == y) {
      vec.push_back(i + 1);
      s.clear();
    }
  }
  if (vec.size() == 1) {
    cout << "-1\n";
    return 0;
  }
  if (vec[vec.size() - 1] != n) {
    vec.erase(vec.begin() + vec.size() - 1, vec.begin() + vec.size());
    vec.push_back(n);
  }
  cout << vec.size() - 1 << endl;
  for (int i = 0; i < vec.size() - 1; i++)
    cout << vec[i] + 1 << " " << vec[i + 1] << endl;
}
