#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define print(a) cout<<a<<endl
typedef long long ll;
#define yn(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YN(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define so(a) sort(a.begin(),a.end())
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define pb push_back
#define a2i(a,s) (ll)(a-s)
#define i2a(s,a) (char)(s+a)
#define ssize(a) a.size()
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<pair<ll,ll>,ll> P3;
typedef pair<pair<ll,ll>,pair<ll,ll>> P4;
typedef pair<ll, ll> Pll;
typedef pair<ll,Pll> Plll;
typedef pair<Pii, int> Piii;
const ll INF = 1000000000000000000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using ull=unsigned long long;
int main(){
//入力
cin.tie(0);
ios::sync_with_stdio(0);
ll t,n;
cin>>t>>n;
map<ll,vector<ll> > mp;
vector<ll> a(n);
rep(i,n)cin>>a[i];
rep(i,n){
mp[a[i]].push_back(i);
}
//判定
priority_queue<Plll> que;
ll p=0;
for(ll i=0;i<n;i++){
if(mp[i].size()<=1)continue;
que.push({mp[i][0],{mp[i][mp[i].size()-2],i}});
que.push({mp[i][1],{mp[i][mp[i].size()-1],i}});
p++;
}
vector<ll> V(n);//入ったかどうか
//判定
ll ans=INF,l=0,r=0;
multiset<ll> st;
ll P=0;
for(ll i=n-1;i>=0;i--){
while(!que.empty()){
// cout<<1<<endl;
ll pos=que.top().second.second,x=que.top().first,y=que.top().second.first;
if(x>=i){
que.pop();
if(V[pos]==0){
V[pos]=1;
P++;
}else{
st.erase(st.find(mp[pos][mp[pos].size()-1]));
}
st.insert(y);
}else break;
}
if(p==P){
ll v2=*st.rbegin();
if(ans>v2-i){
ans=v2-i;
l=i;
r=v2;
}
}
}
cout<<l<<" "<<r<<endl;
return 0;
}