#include<bits/stdc++.h>
using namespace std ;
const int N = 5e5+5 ;
int t , n , arr[N] , cnt[N] , cur[N] , le , ri ;
multiset<int> mst ;
tuple<int,int,int> ans ;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) ;
cin >> t >> n ;
for(int i=0 ; i<n ; i++) cin >> arr[i] , cnt[arr[i]]++ ;
for(int i=0 ; i<t ; i++){
for(int j=1 ; j<cnt[i] ; j++) mst.insert(i) ;
}
ans = {n,0,n-1} ; ri = -1 ;
while(!mst.empty()){
ri++ ; cur[arr[ri]]++ ;
if(mst.find(arr[ri])!=mst.end()) mst.erase(mst.find(arr[ri])) ;
}
for(le=0 ; le<n && ri<n ; le++){
ans = min(ans,{ri-le+1,le,ri}) ;
cur[arr[le]]-- ;
while(ri<n && cnt[arr[le]]-cur[arr[le]]>1){
ri++ ; if(ri==n) break ;
cur[arr[ri]]++ ;
}
}
cout << get<1>(ans) << ' ' << get<2>(ans) << '\n' ;
return 0 ;
}