#include <bits/stdc++.h>
using namespace std;

int LastIndex(int arr[], int size, int idx, int x){
	if(idx == size){
		return -1;
	}
	int liisa = LastIndex(arr, size, idx + 1, x);
	if(liisa == -1){
		if(arr[idx] == x){
			return idx;
		} else {
			return -1;
		}
	} else {
		return liisa;
	}
}

int main(){
	int n;
	cin>>n;
	int arr[n];
	int length = sizeof(arr)/sizeof(arr[0]);
	for(int i = 0; i < length; i++){
		cin>>arr[i];
	}
	int data;
	cin>>data;
	int li = LastIndex(arr, length, 0, data);
	cout<<li<<endl;
}
