#include<bits/stdc++.h>
int* search(int* N, int S, int T)
{
int* R=(int*)malloc(sizeof(int)*(2));
R[0]=-1,R[1]=-1;
int l=0,r=S-1;
while(l<=r)
{
if(N[l]!=T) l++;
else R[0]=l;
if(N[r]!=T) r--;
else R[1]=r;
if(R[0]!=-1&&R[1]!=-1) break;
}
return R;
}
int main()
{
int n,t,*ans;
scanf("%d",&n);
int num[n];
for(int i=0;i<n;i++) scanf("%d",&num[i]);
scanf("%d",&t);
ans=search(num,n,t);
printf("%d %d",ans[0],ans[1]);
return 0;
}