#include<iostream> #include<algorithm> #include<fstream> #include<string> #include<vector> #include<stack> #include<queue> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<map> #include<set> #define FF(i, a, b) for(int i=a; i<b; i++) #define FD(i, a, b) for(int i=a; i>b; i--) #define CLR(a, b) memset(a, b, sizeof(a)) #define REP(i, n) for(int i=0; i<n; i++) #define LL long long #define CPY(a, b) memcpy(a, b, sizeof(b)) using namespace std; int n, k, l, r, a, vis[100005]; int main() { while(~scanf("%d%d", &n, &k)) { CLR(vis, 0); queue<int> q; LL ans = -1, cnt = 0, tmp = 0; int j = 1; FF(i, 1, n+1) { scanf("%d", &a); if(!vis[a]) cnt++; vis[a]++; q.push(a); tmp += a; while(vis[q.front()] > 1) { vis[q.front()] -= 1; q.pop(); j++; tmp -= q.front(); } if(cnt > k) { vis[q.front()]--; q.pop(); ++; tmp -= q.front(); } if(cnt == k && (ans == -1 || ans > tmp)) { ans = tmp, r = i; } } if(ans == -1) puts("-1 -1"); else printf("%d %d\n", l, r); } return 0; }