#include <bits/stdc++.h>
using namespace std;
/*二分查找中间元素*/
int BSCommon(const vector<int> &num,const int &target){
int left = 0,right = num.size() - 1;
while(left <= right){
int mid = left + (right - left) / 2;
if(num[mid] == target)
return mid;
else if(num[mid] < target)
left = mid + 1;
else
right = mid - 1;
}
return -1;
}
/*二分查找左边界*/
int BSLeftBoundary(const vector<int> &num,const int &target){
int left = 0,right = num.size() - 1;
while(left <= right){
int mid = left + (right - left) / 2;
if(num[mid] < target)
left = mid + 1;
else
right = mid - 1;
}
if(left < num.size() && num[left] == target)
return left;
return -1;
}
/*二分查找右边界*/
int BSRightBoundary(const vector<int> &num,const int &target){
int left = 0,right = num.size() - 1;
while(left <= right){
int mid = left + (right - left) / 2;
if(num[mid] > target)
right = mid - 1;
else
left = mid + 1;
}
if(right >= 0 && num[right] == target)
return right;
return -1;
}
/*在有序数组中找到第一个>=key的元素下标*/
int FindFirstGreater(vector<int> &num,int key){
sort(num.begin(),num.end(),less<int>());
int left = 0,right = num.size() - 1;
int mid,ans = -1;
while(left <= right){
mid = left + (right - left) / 2;
if(num[mid] >= key){
ans = mid;
right = mid - 1;
}
else
left = mid + 1;
}
return ans;
}
int main(){
int n;
int t;
while(cin >> n){
vector<int> num(n,0);
for(auto i = 0;i<n;++i)
cin>>num[i];
cin>>t;
cout<<BSCommon(num,t)<<endl;
cout<<BSLeftBoundary(num,t)<<endl;
cout<<BSRightBoundary(num,t)<<endl;
}
}