#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 50;
int a[N];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", a + i);
    vector<pair<int, int>> ans;
    set<int> s;
    int last = 0;
    for (int i = 1; i <= n; i++)
        if (s.empty())
            s.insert(a[last = i]);
        else if (s.count(a[i]))
            ans.push_back(make_pair(last, i)), s.clear();
        else
            s.insert(a[i]);
    if (ans.empty())
        puts("-1");
    else
    {
        ans.rbegin()->second = n;
        printf("%d\n", ans.size());
        for (auto &x : ans)
            printf("%d %d\n", x.first, x.second);
    }
    return 0;
}