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

bool identical(vector<int>v,int k){
	map<int,int>m;
	for(int i=0;i<v.size();i++){
		if(m[v[i]]==0){
			m[v[i]]=i+1;
		}else{
			if((i+1-m[v[i]])<=k){
				return true;
			}else{
			  m[v[i]]=i+1;
			}
		}
	}
	return false;
}

int main() {
	// your code goes here
	int n;cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	int k;cin>>k;
	if(identical(v,k)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}