#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<assert.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1LL<<62;
const int mod=1e9+7;

int qpow(int x,int y) {
	int ans=1;
	while (y) {
		if (y&1) ans=1LL*ans*x%mod;
		x=1LL*x*x%mod;y>>=1;
	}
	return ans;
}

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

namespace io {
	const int L=(1<<21)+1;
	char ibuf[L],*iS,*iT,obuf[L],*oS=obuf,*oT=obuf+L-1,c,st[55];int f,tp;
#define gc() (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,L,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline char getc() {
		return gc();
	}
	inline void flush() {
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	inline void putc(char x) { *oS++=x; if (oS==oT) flush(); }
	template<class I> inline bool gi(I&x) {
		for (f=1,c=gc();c<'0'||c>'9';c=gc()) if (c=='-') f=-1; else if (c==-1) return false;
		for (x=0;c<='9'&&c>='0';c=gc()) x=x*10+(c&15); x*=f;
		return true;
	}
	template<class I> inline void print(I x) {
		if (!x) putc('0');
		if (x<0) putc('-'),x=-x;
		while (x) st[++tp]=x%10+'0',x/=10;
		while (tp) putc(st[tp--]);
	}
	inline bool gs(char*s, int&l) {
		for (c=gc();c<'a'||c>'z';c=gc()) if (c==-1) return false;
		for (l=0;c<='z'&&c>='a';c=gc()) s[l++]=c;
		s[l]=0;
		return true;
	}
	inline void printld(double x, int digit) {
		if (x < 0) putc('-'), x = -x;
		x += 0.5 * pow(0.1, digit);
		print((LL)x), putc('.');
		for (x -= (LL)x; digit; --digit) x = x * 10, putc((int)x + '0'), x -= (int)x;
	}
	inline void ps(const char*s) { for (int i=0,n=strlen(s);i<n;i++) putc(s[i]); }
	struct IOFLUSHER{ ~IOFLUSHER() { flush(); } } _ioflusher_;
};
using io::getc;
using io::putc;
using io::gi;
using io::gs;
using io::ps;
using io::print;
using io::printld;

const int N=140582;

LL a[N],b[N];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int n,i,k;
	gi(n);
	for (i=0;i<n;i++)
		gi(b[i]);
	for (k=0;k<n;k++)
		if (b[k]<b[(k+1)%n])
			break;
	if (k==n) {
		if (!b[0]) {
			ps("YES");
			for (i=0;i<n;i++)
				ps("1 ");
		} else ps("NO");
		exit(0);
	}
	a[(k+1)%n]=b[(k+1)%n];
	for (i=k;i!=(k+1)%n;i=(i+n-1)%n) {
		a[i]=a[(i+1)%n]+b[i];
		if (a[i]<oo) a[i]+=(oo-a[i])/a[(i+1)%n]*a[(i+1)%n];
	}
	for (i=0;i<n;i++)
		if (a[i]%a[(i+1)%n]!=b[i])
			return ps("NO"),0;
	ps("YES\n");
	for (i=0;i<n;i++)
		print(a[i]),putc(" \n"[i==n-1]);

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<assert.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1LL<<62;
const int mod=1e9+7;

int qpow(int x,int y) {
	int ans=1;
	while (y) {
		if (y&1) ans=1LL*ans*x%mod;
		x=1LL*x*x%mod;y>>=1;
	}
	return ans;
}

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

namespace io {
	const int L=(1<<21)+1;
	char ibuf[L],*iS,*iT,obuf[L],*oS=obuf,*oT=obuf+L-1,c,st[55];int f,tp;
#define gc() (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,L,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline char getc() {
		return gc();
	}
	inline void flush() {
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	inline void putc(char x) { *oS++=x; if (oS==oT) flush(); }
	template<class I> inline bool gi(I&x) {
		for (f=1,c=gc();c<'0'||c>'9';c=gc()) if (c=='-') f=-1; else if (c==-1) return false;
		for (x=0;c<='9'&&c>='0';c=gc()) x=x*10+(c&15); x*=f;
		return true;
	}
	template<class I> inline void print(I x) {
		if (!x) putc('0');
		if (x<0) putc('-'),x=-x;
		while (x) st[++tp]=x%10+'0',x/=10;
		while (tp) putc(st[tp--]);
	}
	inline bool gs(char*s, int&l) {
		for (c=gc();c<'a'||c>'z';c=gc()) if (c==-1) return false;
		for (l=0;c<='z'&&c>='a';c=gc()) s[l++]=c;
		s[l]=0;
		return true;
	}
	inline void printld(double x, int digit) {
		if (x < 0) putc('-'), x = -x;
		x += 0.5 * pow(0.1, digit);
		print((LL)x), putc('.');
		for (x -= (LL)x; digit; --digit) x = x * 10, putc((int)x + '0'), x -= (int)x;
	}
	inline void ps(const char*s) { for (int i=0,n=strlen(s);i<n;i++) putc(s[i]); }
	struct IOFLUSHER{ ~IOFLUSHER() { flush(); } } _ioflusher_;
};
using io::getc;
using io::putc;
using io::gi;
using io::gs;
using io::ps;
using io::print;
using io::printld;

const int N=140582;

LL a[N],b[N];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int n,i,k;
	gi(n);
	for (i=0;i<n;i++)
		gi(b[i]);
	for (k=0;k<n;k++)
		if (b[k]<b[(k+1)%n])
			break;
	if (k==n) {
		if (!b[0]) {
			ps("YES\n");
			for (i=0;i<n;i++)
				ps("1 ");
		} else ps("NO");
		exit(0);
	}
	a[(k+1)%n]=b[(k+1)%n];
	for (i=k;i!=(k+1)%n;i=(i+n-1)%n) {
		a[i]=a[(i+1)%n]+b[i];
		if (a[i]<oo) a[i]+=(oo-a[i])/a[(i+1)%n]*a[(i+1)%n];
	}
	for (i=0;i<n;i++)
		if (a[i]%a[(i+1)%n]!=b[i])
			return ps("NO"),0;
	ps("YES\n");
	for (i=0;i<n;i++)
		print(a[i]),putc(" \n"[i==n-1]);

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<assert.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1LL<<62;
const int mod=1e9+7;

int qpow(int x,int y) {
	int ans=1;
	while (y) {
		if (y&1) ans=1LL*ans*x%mod;
		x=1LL*x*x%mod;y>>=1;
	}
	return ans;
}

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

namespace io {
	const int L=(1<<21)+1;
	char ibuf[L],*iS,*iT,obuf[L],*oS=obuf,*oT=obuf+L-1,c,st[55];int f,tp;
#define gc() (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,L,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline char getc() {
		return gc();
	}
	inline void flush() {
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	inline void putc(char x) { *oS++=x; if (oS==oT) flush(); }
	template<class I> inline bool gi(I&x) {
		for (f=1,c=gc();c<'0'||c>'9';c=gc()) if (c=='-') f=-1; else if (c==-1) return false;
		for (x=0;c<='9'&&c>='0';c=gc()) x=x*10+(c&15); x*=f;
		return true;
	}
	template<class I> inline void print(I x) {
		if (!x) putc('0');
		if (x<0) putc('-'),x=-x;
		while (x) st[++tp]=x%10+'0',x/=10;
		while (tp) putc(st[tp--]);
	}
	inline bool gs(char*s, int&l) {
		for (c=gc();c<'a'||c>'z';c=gc()) if (c==-1) return false;
		for (l=0;c<='z'&&c>='a';c=gc()) s[l++]=c;
		s[l]=0;
		return true;
	}
	inline void printld(double x, int digit) {
		if (x < 0) putc('-'), x = -x;
		x += 0.5 * pow(0.1, digit);
		print((LL)x), putc('.');
		for (x -= (LL)x; digit; --digit) x = x * 10, putc((int)x + '0'), x -= (int)x;
	}
	inline void ps(const char*s) { for (int i=0,n=strlen(s);i<n;i++) putc(s[i]); }
	struct IOFLUSHER{ ~IOFLUSHER() { flush(); } } _ioflusher_;
};
using io::getc;
using io::putc;
using io::gi;
using io::gs;
using io::ps;
using io::print;
using io::printld;

const int N=140582;

LL a[N],b[N];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int n,i,k;
	gi(n);
	for (i=0;i<n;i++)
		gi(b[i]);
	for (k=0;k<n;k++)
		if (b[k]<b[(k+1)%n])
			break;
	if (k==n) {
		if (!b[0]) {
			ps("YES");
			for (i=0;i<n;i++)
				ps("1 ");
		} else ps("NO");
		exit(0);
	}
	a[k]=b[k];
	for (i=(k+n-1)%n;i!=k;i=(i+n-1)%n) {
		a[i]=a[(i+1)%n]+b[i];
		if (a[i]<oo) a[i]+=(oo-a[i])/a[(i+1)%n]*a[(i+1)%n];
	}
	for (i=0;i<n;i++)
		if (a[i]%a[(i+1)%n]!=b[i])
			return ps("NO"),0;
	ps("YES\n");
	for (i=0;i<n;i++)
		print(a[i]),putc(" \n"[i==n-1]);

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<assert.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1LL<<62;
const int mod=1e9+7;

int qpow(int x,int y) {
	int ans=1;
	while (y) {
		if (y&1) ans=1LL*ans*x%mod;
		x=1LL*x*x%mod;y>>=1;
	}
	return ans;
}

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

namespace io {
	const int L=(1<<21)+1;
	char ibuf[L],*iS,*iT,obuf[L],*oS=obuf,*oT=obuf+L-1,c,st[55];int f,tp;
#define gc() (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,L,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline char getc() {
		return gc();
	}
	inline void flush() {
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	inline void putc(char x) { *oS++=x; if (oS==oT) flush(); }
	template<class I> inline bool gi(I&x) {
		for (f=1,c=gc();c<'0'||c>'9';c=gc()) if (c=='-') f=-1; else if (c==-1) return false;
		for (x=0;c<='9'&&c>='0';c=gc()) x=x*10+(c&15); x*=f;
		return true;
	}
	template<class I> inline void print(I x) {
		if (!x) putc('0');
		if (x<0) putc('-'),x=-x;
		while (x) st[++tp]=x%10+'0',x/=10;
		while (tp) putc(st[tp--]);
	}
	inline bool gs(char*s, int&l) {
		for (c=gc();c<'a'||c>'z';c=gc()) if (c==-1) return false;
		for (l=0;c<='z'&&c>='a';c=gc()) s[l++]=c;
		s[l]=0;
		return true;
	}
	inline void printld(double x, int digit) {
		if (x < 0) putc('-'), x = -x;
		x += 0.5 * pow(0.1, digit);
		print((LL)x), putc('.');
		for (x -= (LL)x; digit; --digit) x = x * 10, putc((int)x + '0'), x -= (int)x;
	}
	inline void ps(const char*s) { for (int i=0,n=strlen(s);i<n;i++) putc(s[i]); }
	struct IOFLUSHER{ ~IOFLUSHER() { flush(); } } _ioflusher_;
};
using io::getc;
using io::putc;
using io::gi;
using io::gs;
using io::ps;
using io::print;
using io::printld;

const int N=140582;

LL a[N],b[N];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int n,i,k;
	gi(n);
	for (i=0;i<n;i++)
		gi(b[i]);
	k=max_element(b,b+n)-b;
	a[k]=b[k];
	for (i=(k+n-1)%n;i!=k;i=(i+n-1)%n)
		a[i]=b[i]+a[(i+1)%n]*2;
	for (i=0;i<n;i++)
		if (a[i]%a[(i+1)%n]!=b[i])
			return ps("NO"),0;
	ps("YES\n");
	for (i=0;i<n;i++)
		print(a[i]),putc(" \n"[i==n-1]);
	return 0;
}


#include <cstdio>

int get() {
	int x = 0; char s = getchar();
	while (s < '0' || s > '9') s = getchar();
	while (s >= '0' && s <= '9') x = (x << 3) + (x << 1) + (s ^ 48), s = getchar();
	return x;
}

int Max(const int x, const int y) {
	if(x > y) return x;
	return y;
}

const int M = 140600;
int a[M], b[M], c[M], n, mx;

int main() {
	n = get();
	bool pd = 1;
	for (int i = 1; i <= n; ++i) {
		if(b[i] = get())
			pd = 0;
		c[i] = b[i];
		mx = Max(mx, b[i]);
	}
	if(pd) {
		printf("YES\n");
		for (int i = 1; i <= n; ++i) printf("1 ");
		return 0;
	}
	int pos = 1;
	b[0] = b[n];
	for (int i = 1; i <= n; ++i)
		if(b[i] == mx && b[i - 1] != b[i])
			pos = i;
	a[pos] = b[pos];
	int t = pos == 1 ? n : pos - 1;
	if(!b[t]) c[t] = c[pos];
	for (int i = pos - 1; i >= 1; --i) a[i] = a[i % n + 1] + c[i];
	for (int i = n; i > pos; --i) a[i] = a[i % n + 1] + c[i];
	for (int i = 1; i <= n; ++i)
		if(!a[i % n + 1] || a[i] % a[i % n + 1] != b[i])
			return !printf("NO");
	printf("YES\n");
	for (int i = 1; i <= n; ++i) printf("%d ", a[i]);
	return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;
#define ll long long
#define MAXN 141000
int n;
ll Max;
ll a[MAXN], b[MAXN], c[MAXN];

int main() {
	scanf( "%d", &n );
	for( int i = 1;i <= n;i ++ ) {
		scanf( "%lld", &b[i] );
		Max = max( Max, b[i] );
		c[i] = b[i];
	}
	int pos;
	for( int i = 1;i <= n;i ++ )
		if( b[i] == Max && b[i - 1] != b[i] ) pos = i;
	if( ! Max ) {
		printf( "YES\n" );
		for( int i = 1;i <= n;i ++ ) printf( "1 " );
		return 0;
	}
	a[pos] = c[pos] = b[pos];
	int pre = ( pos == 1 ) ? n : pos - 1;
	if( ! b[pre] ) c[pre] = c[pos];
	for( int i = pre;i > 0;i -- ) a[i] = a[i + 1] + c[i];
	for( int i = n;i > pos;i -- ) a[i] = a[i % n + 1] + c[i];
	for( int i = 1;i <= n;i ++ )
		if( ( ! a[i % n + 1] ) || ( a[i] % a[i % n + 1] != b[i] ) ) return ! printf( "NO" );
	printf( "YES\n" );
	for( int i = 1;i <= n;i ++ )
		printf( "%lld ", a[i] );
	return 0;
}


#include <cstdio>

int get() {
	int x = 0; char s = getchar();
	while (s < '0' || s > '9') s = getchar();
	while (s >= '0' && s <= '9') x = (x << 3) + (x << 1) + (s ^ 48), s = getchar();
	return x;
}

int Max(const int x, const int y) {
	if(x > y) return x;
	return y;
}

const int M = 140600;
int a[M], b[M], c[M], n, mx;

int main() {
	n = get();
	bool pd = 1;
	for (int i = 1; i <= n; ++i) {
		if(b[i] = get())
			pd = 0;
		c[i] = b[i];
		mx = Max(mx, b[i]);
	}
	if(pd) {
		printf("YES\n");
		for (int i = 1; i <= n; ++i) printf("1 ");
		return 0;
	}
	int pos = 1;
	b[0] = b[n];
	for (int i = 1; i <= n; ++i)
		if(b[i] == mx && b[i - 1] != b[i])
			pos = i;
	a[pos] = b[pos];
	int t = pos == 1 ? n : pos - 1;
	if(!b[t]) c[t] = c[pos];
	for (int i = pos - 1; i >= 1; --i) a[i] = a[i + 1] + c[i];
	for (int i = n; i > pos; --i) a[i] = a[i % n + 1] + c[i];
	for (int i = 1; i <= n; ++i)
		if(!a[i % n + 1] || a[i] % a[i % n + 1] != b[i])
			return !printf("NO");
	printf("YES\n");
	for (int i = 1; i <= n; ++i) printf("%d ", a[i]);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<queue>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int n,ind;
long long a[200005],b[200005],maxn = -1;
bool flag;
int main(){
	scanf ("%d",&n);
	for (int i = 1;i <= n;i ++)
		scanf ("%lld",&b[i]);
	for (int i = 1;i < n;i ++){
		if (b[i] != b[i + 1]){
			flag = 1;
			break;
		}
	}
	if (!flag){
		if (b[1] == 0){
			printf("YES\n");
			for (int i = 1;i < n;i ++)
				printf("1 ");
			printf("1\n");
			return 0;
		}
		else {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for (int i = 1;i <= n;i ++){
		if (maxn < b[i]){
			maxn = b[i];
			ind = i;
		}
	}
	for (int i = 1;i <= n;i ++){
		if (b[i] == maxn){
			int j = i - 1;
			if (j < 0)
				j = n;
			if (b[j] < b[i])
				ind = i;
		}
	}
	a[ind] = b[ind];
	for (int i = n;i > 1;i --){
		ind --;
		if (ind <= 0)
			ind = n;
		int j = ind + 1;
		if (j > n)
			j = 1;
		for (int k = 0;;k ++){
			if (b[ind] + a[j] * k > b[ind - 1 <= 0?n:ind - 1]){
				a[ind] = b[ind] + a[j] * k;
				break;
			}
		}
	}
	for (int i = 1;i < n;i ++)
		printf("%lld ",a[i]);
	printf("%lld\n",a[n]);
}


#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=140582+10;
int n,S=-1;
long long c[N],a[N],b[N];
#define l(i) ((i-1+n)%n)
#define r(i) ((i+1)%n)
int main()
{
	n=read();
	for(int i=0;i<n;i++)scanf("%I64d",&b[i]);
	for(int i=0;i<n;i++)
	if(b[i]>b[l(i)]){S=i;break;}
	if(S==-1){
		if(b[0]==0){
			printf("YES\n");
			for(int i=1;i<=n;i++)
			printf("%d ",1);
		}
		else printf("NO\n");
		return 0;
	}
	c[S]=0;a[S]=b[S];
	for(int i=1;i<n;i++){
		int u=(S-i+n)%n;
		if(b[u]>b[l(u)]){c[u]=0;a[u]=b[u];continue;}
		c[u]=(b[l(u)]-b[u])/a[r(u)]+1;
		a[u]=c[u]*a[r(u)]+b[u];
	}
	printf("YES\n");
	for(int i=0;i<n;i++)
	printf("%I64d ",a[i]);
	return 0;
}


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

int main(){
    int n, ma, pos;
    ma = 0;
    cin >> n;
    int b[2*n];
    long long a[n];
    for(int i = 0; i<n; i++){
        cin >> b[i];
        ma = max(ma, b[i]);
        b[n+i] = b[i];
    }

    for(int i = 1; i<=n; i++){
        if(b[i] == ma && b[i-1] != ma){
            pos = (i % n);
            a[pos] = b[pos];
            for(int j = pos + n - 1; j>pos; j--){
                a[j % n] = a[(j + 1) % n] + b[j];
            }

            cout << "YES" << endl;
            for(int j = 0; j<n; j++){
                cout << a[j] << " ";
            }
            return 0;
        }

        if(i == n){
            cout << "NO";
            return 0;
        }
    }

}


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

int main(){
    int n, ma, pos, zero, skap;
    skap = 0;
    zero = 0;
    ma = 0;
    cin >> n;
    int b[2*n];
    long long a[n];
    for(int i = 0; i<n; i++){
        cin >> b[i];
        if(b[i] == 0) zero++;
        ma = max(ma, b[i]);
        b[n+i] = b[i];
    }

    if(zero == n - 1){
        cout << "NO";
        return 0;
    }

    for(int i = 1; i<=n; i++){
        if(b[i] == ma && b[i-1] != ma){
            pos = (i % n);
            a[pos] = b[pos];
            for(int j = pos + n - 1; j>pos; j--){

                if(skap == 0 && b[j] == 0){
                    a[j % n] = 2 * a[(j + 1) % n] + b[j];
                    skap = 1;
                }
                else a[j % n] = a[(j + 1) % n] + b[j];
            }

            cout << "YES" << endl;
            for(int j = 0; j<n; j++){
                cout << a[j] << " ";
            }
            return 0;
        }

        if(i == n && b[i] > 0){
            cout << "NO";
            return 0;
        }

        if(i == n && b[i] == 0){
            cout << "YES" << endl;
            for(int j = 0; j<n; j++){
                cout << 1 << " ";
            }
            return 0;
        }
    }

}


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

int main(){
    int n, ma, pos, zero, skap;
    skap = 0;
    zero = 0;
    ma = 0;
    cin >> n;
    int b[2*n];
    long long a[n];
    for(int i = 0; i<n; i++){
        cin >> b[i];
        if(b[i] == 0) zero++;
        ma = max(ma, b[i]);
        b[n+i] = b[i];
    }

    if(zero == n - 1){
        cout << "NO";
        return 0;
    }

    for(int i = 1; i<=n; i++){
        if(b[i] == ma && b[i-1] != ma){
            pos = (i % n);
            a[pos] = b[pos];
            for(int j = pos + n - 1; j>pos; j--){
                cout << b[j] << endl;
                if(skap == 0 && b[j] == 0){
                    a[j % n] = 2 * a[(j + 1) % n] + b[j];
                    skap = 1;
                }
                else a[j % n] = a[(j + 1) % n] + b[j];
            }

            cout << "YES" << endl;
            for(int j = 0; j<n; j++){
                cout << a[j] << " ";
            }
            return 0;
        }

        if(i == n && b[i] > 0){
            cout << "NO";
            return 0;
        }

        if(i == n && b[i] == 0){
            for(int j = 0; j<n; j++){
                cout << 1 << " ";
            }
            return 0;
        }
    }

}


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

int main(){
    int n, ma, pos, zero;
    zero = 0;
    ma = 0;
    cin >> n;
    int b[2*n];
    long long a[n];
    for(int i = 0; i<n; i++){
        cin >> b[i];
        if(b[i] == 0) zero++;
        ma = max(ma, b[i]);
        b[n+i] = b[i];
    }

    if(zero == n - 1){
        cout << "NO";
        return 0;
    }

    for(int i = 1; i<=n; i++){
        if(b[i] == ma && b[i-1] != ma){
            pos = (i % n);
            a[pos] = b[pos];
            for(int j = pos + n - 1; j>pos; j--){
                a[j % n] = a[(j + 1) % n] + b[j];
            }

            cout << "YES" << endl;
            for(int j = 0; j<n; j++){
                cout << a[j] << " ";
            }
            return 0;
        }

        if(i == n && b[i] > 0){
            cout << "NO";
            return 0;
        }

        if(i == n && b[i] == 0){
            for(int j = 0; j<n; j++){
                cout << 1 << " ";
            }
            return 0;
        }
    }

}


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

int main(){
    int n, ma, pos, zero, skap;
    skap = 0;
    zero = 0;
    ma = 0;
    cin >> n;
    int b[2*n];
    long long a[n];
    for(int i = 0; i<n; i++){
        cin >> b[i];
        if(b[i] == 0) zero++;
        ma = max(ma, b[i]);
        b[n+i] = b[i];
    }

    for(int i = 1; i<=n; i++){
        if(b[i] == ma && b[i-1] != ma){
            pos = (i % n);
            a[pos] = b[pos];
            for(int j = pos + n - 1; j>pos; j--){

                if(skap == 0 && b[j] == 0){
                    a[j % n] = 2 * a[(j + 1) % n] + b[j];
                    skap = 1;
                }
                else a[j % n] = a[(j + 1) % n] + b[j];
            }

            cout << "YES" << endl;
            for(int j = 0; j<n; j++){
                cout << a[j] << " ";
            }
            return 0;
        }

        if(i == n && b[i] > 0){
            cout << "NO";
            return 0;
        }

        if(i == n && b[i] == 0){
            cout << "YES" << endl;
            for(int j = 0; j<n; j++){
                cout << 1 << " ";
            }
            return 0;
        }
    }

}


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

int main(){
    int n, ma, pos, zero, skap;
    skap = 0;
    zero = 0;
    ma = 0;
    cin >> n;
    int b[2*n];
    long long a[n];
    for(int i = 0; i<n; i++){
        cin >> b[i];
        if(b[i] == 0) zero++;
        ma = max(ma, b[i]);
        b[n+i] = b[i];
    }

    if(zero == n - 1){
        cout << "NO";
        return 0;
    }

    for(int i = 1; i<=n; i++){
        if(b[i] == ma && b[i-1] != ma){
            pos = (i % n);
            a[pos] = b[pos];
            for(int j = pos + n - 1; j>pos; j--){

                if(skap == 0 && b[j] == 0){
                    a[j % n] = 2 * a[(j + 1) % n] + b[j];
                    skap = 1;
                }
                else a[j % n] = a[(j + 1) % n] + b[j];
            }

            cout << "YES" << endl;
            for(int j = 0; j<n; j++){
                cout << a[j] << " ";
            }
            return 0;
        }

        if(i == n && b[i] > 0){
            cout << "NO";
            return 0;
        }

        if(i == n && b[i] == 0){
            for(int j = 0; j<n; j++){
                cout << 1 << " ";
            }
            return 0;
        }
    }

}


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

int main(){
    int n, ma, pos;
    ma = 0;
    cin >> n;
    int b[2*n];
    long long a[n];
    for(int i = 0; i<n; i++){
        cin >> b[i];
        ma = max(ma, b[i]);
        b[n+i] = b[i];
    }

    for(int i = 1; i<=n; i++){
        if(b[i] == ma && b[i-1] != ma){
            pos = (i % n);
            a[pos] = b[pos];
            for(int j = pos + n - 1; j>pos; j--){
                a[j % n] = a[(j + 1) % n] + b[j];
            }

            cout << "YES" << endl;
            for(int j = 0; j<n; j++){
                cout << a[j] << " ";
            }
            return 0;
        }

        if(i == n && b[i] > 0){
            cout << "NO";
            return 0;
        }

        if(i == n && b[i] == 0){
            for(int j = 0; j<n; j++){
                cout << 1 << " ";
            }
            return 0;
        }
    }

}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<cstring>
#include<map>
#include<stack>
#include<utility>
using namespace std;
#define ll long long
const int N=2e5+5;
ll arr[N],ans[N];
int main(){
	int n;
	cin>>n;
	bool flag=0;
	ll tmp=0;
	for(int i =0;i<n;i++)
		cin>>arr[i];
	for(int i=1;i<=n;i++){
		if(arr[i%n]!=arr[i-1]&&arr[i%n]!=0&&(arr[i%n]>arr[i-1])){
			flag=1;
			ans[i%n]=arr[i%n];
			tmp=N*ans[i%n];
			int j=i%n;
			i--;
			while(i!=j){
				if(i<0)
				i+=n;
				tmp+=arr[i];
				ans[i]=tmp;
				i--;
			}
			break;
		}
	}
	if(flag){
		cout<<"YES\n";
		for(int i=0;i<n;i++)
			cout<<ans[i]<<" ";
	}
	else{
		int zer=1;
		for(int i=0;i<n;i++)
			if(arr[i]!=0)
				zer=0;
		if(zer){
			cout<<"YES\n";
			for(int i=0;i<n;i++)
				cout<<"1 ";
		}
		else
		cout<<"NO";
	}
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<cstring>
#include<map>
#include<stack>
#include<utility>
using namespace std;
#define ll long long
const ll N=2e5+5;
ll bs=2e5;
ll arr[N],ans[N];
int main(){
	ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	int n;
	cin>>n;
	bool flag=0;
	ll tmp=0;
	for(int i =0;i<n;i++)
		cin>>arr[i];
	for(int i=1;i<=n;i++){
		if(arr[i%n]!=arr[i-1]&&arr[i%n]!=0&&(arr[i%n]>arr[i-1])){
			flag=1;
			ans[i%n]=arr[i%n];
			tmp=bs*ans[i%n];
			int j=i%n;
			i--;
			while(i!=j){
				if(i<0)
				i+=n;
				tmp+=arr[i];
				ans[i]=tmp;
				i--;
if(i<0)i+=n;
			}
			break;
		}
	}
	if(flag){
		cout<<"YES\n";
		for(int i=0;i<n;i++)
			cout<<ans[i]<<" ";
	}
	else{
		int zer=1;
		for(int i=0;i<n;i++)
			if(arr[i]!=0){
				zer=0;
				break;
			}
		if(zer){
			cout<<"YES\n";
			for(int i=0;i<n;i++)
				cout<<"1 ";
		}
		else
		cout<<"NO";
	}
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<cstring>
#include<map>
#include<stack>
#include<utility>
using namespace std;
#define ll long long
const int N=2e5+5;
ll arr[N],ans[N];
int main(){
	ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	int n;
	cin>>n;
	bool flag=0;
	ll tmp=0;
	for(int i =0;i<n;i++)
		cin>>arr[i];
	for(int i=1;i<=n;i++){
		if(arr[i%n]!=arr[i-1]&&arr[i%n]!=0&&(arr[i%n]>arr[i-1])){
			flag=1;
			ans[i%n]=arr[i%n];
			tmp=N*ans[i%n];
			int j=i%n;
			i--;
			while(i!=j){
				if(i<0)
				i+=n;
				tmp+=arr[i];
				ans[i]=tmp;
				i--;
			}
			break;
		}
	}
	if(flag){
		cout<<"YES\n";
		for(int i=0;i<n;i++)
			cout<<ans[i]<<" ";
	}
	else{
		int zer=1;
		for(int i=0;i<n;i++)
			if(arr[i]!=0)
				zer=0;
		if(zer){
			cout<<"YES\n";
			for(int i=0;i<n;i++)
				cout<<"1 ";
		}
		else
		cout<<"NO";
	}
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<cstring>
#include<map>
#include<stack>
#include<utility>
using namespace std;
#define ll long long
const int N=2e5+5;
ll arr[N],ans[N];
int main(){
	int n;
	cin>>n;
	bool flag=0;
	ll tmp=0;
	for(int i =0;i<n;i++)
		cin>>arr[i];
	for(int i=1;i<=n;i++){
		if(arr[i%n]!=arr[i-1]&&arr[i%n]!=0&&(arr[i%n]>arr[i-1])){
			flag=1;
			ans[i%n]=arr[i%n];
			tmp=N*ans[i%n];
			int j=i%n;
			i--;
			while(i!=j){
				if(i<0)
				i+=n;
				tmp+=arr[i];
				ans[i]=tmp;
				i--;
			}
			break;
		}
	}
	if(flag){
		cout<<"YES\n";
		for(int i=0;i<n;i++)
			cout<<ans[i]<<" ";
	}
	else
		cout<<"NO";
}


using System;
using System.IO;
using System.Text;

namespace Fish_Weight
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve() ? "YES" : "NO");
            writer.Flush();
        }

        private static bool Solve()
        {
            int n = Next();
            int m = Next();
            int k = Next();

            if (n > m)
                return true;

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }
            var mm = new int[m];
            for (int i = 0; i < m; i++)
            {
                mm[i] = Next();
            }

            Array.Sort(nn);
            Array.Sort(mm);

            int index = 0;
            foreach (int i in nn)
            {
                while (index < mm.Length && mm[index] < i)
                {
                    index++;
                }
                if (index >= mm.Length || mm[index] > i)
                    return true;

                index++;
            }
            return false;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.IO;
using System.Text;

namespace Fish_Weight
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve() ? "YES" : "NO");
            writer.Flush();
        }

        private static bool Solve()
        {
            int n = Next();
            int m = Next();
            int k = Next();

            if (n > m)
                return true;

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }
            var mm = new int[m];
            for (int i = 0; i < m; i++)
            {
                mm[i] = Next();
            }

            Array.Sort(nn);
            Array.Sort(mm);

            int index = m - 1;

            for (int i = n - 1; i >= 0; i--)
            {
                while (i > 0 && nn[i - 1] == nn[i]) i--;

                while (index >= 0 && mm[index] >= nn[i])
                {
                    index--;
                }
                if (n - i > m - index - 1)
                    return true;

                index++;
            }
            return false;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
//using System.Collections;
//using System.Collections.Specialized;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        if (a < b)
        {
            long t = a;
            a = b;
            b = t;
        }
        return (b > 0) ? gcd(b, a % b) : a;
    }
    static void _235A()
    {
        long n = long.Parse(reader.ReadLine()), ans = n * (n - 1);
        if (n < 3)
            ans = n;
        else if (n % 2 == 1)
            ans *= n - 2;
        else
        {
            long t = (n - 2) / 2;
            for (long i = n - 3; i > (n - 2) / 2; --i)
            {
                long g = gcd(n, i);
                if (g == 1)
                    t = Math.Max(t, i);
            }
            ans *= t;
        }
        writer.Write(Math.Max(ans, (n - 1) * (n - 2) * (n - 3)));
    }
    static void _106C()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), c0 = int.Parse(s[2]), d0 = int.Parse(s[3]);
        int[] a = new int[m + 1], b = new int[m + 1], c = new int[m + 1], d = new int[m + 1];
        for (int i = 1; i <= m; ++i)
        {
            s = reader.ReadLine().Split();
            a[i] = int.Parse(s[0]);
            b[i] = int.Parse(s[1]);
            c[i] = int.Parse(s[2]);
            d[i] = int.Parse(s[3]);
        }
        int[,] dp = new int[m + 1, n + 1];
        for (int i = 1; i * c0 <= n; ++i)
            dp[0, i * c0] = i * d0;
        for (int i = 1; i <= m; ++i)
        {
            for (int j = 1; j <= n; ++j)
            {
                if (j < c[i])
                    dp[i, j] = dp[i - 1, j];
                else
                {
                    for (int k = 0; k * b[i] <= a[i]; ++k)
                    {
                        int t = c[i] * k;
                        if (t <= j)
                            dp[i, j] = Math.Max(d[i] * k + dp[i - 1, j - t], dp[i, j]);
                    }
                }
                dp[i, j] = Math.Max(dp[i, j - 1], dp[i, j]);
            }
        }
        writer.Write(dp[m, n]);
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) != 0)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _300C()
    {
        string[] s = reader.ReadLine().Split();
        long a = long.Parse(s[0]), b = long.Parse(s[1]), n = long.Parse(s[2]);
        if (a > b)
        {
            long t = a;
            a = b;
            b = t;
        }
        long[] fact = new long[n + 1];
        fact[0] = fact[1] = 1;
        long mod = 1000000007;
        for (long i = 2; i <= n; ++i)
            fact[i] = fact[i - 1] * i % mod;
        long an = n, bn = 0;
        long ans = 0;
        while (an >= 0)
        {
            long num = an * a + bn * b;
            bool ok = true;
            for (long p = 10; ok && p <= 10000000; p *= 10)
            {
                long t = num % p / (p / 10);
                if (t != a && t != b && (t != 0 || p <= num))
                    ok = false;
            }
            if (ok)
            {
                long c = (((fact[n] * pow(fact[an], mod - 2, mod)) % mod) * pow(fact[bn], mod - 2, mod)) % mod;
                ans += c;
                ans %= mod;
            }
            --an;
            ++bn;
        }
        writer.Write(ans);
    }
    static void _250B()
    {
        string s = reader.ReadLine();
        int n = int.Parse(s);
        for (int i = 0; i < n; ++i)
        {
            s = reader.ReadLine();
            string[] ip = new string[8];
            int nums = 0;
            for (int l = 0, j = 0; j < s.Length; ++j)
            {
                if (s[j] == ':')
                {
                    if (nums > 0)
                    {
                        //ip[l] = "";
                        for (int k = j - nums; k < j; ++k)
                            ip[l] += s[k];
                        ++l;
                        nums = 0;
                    }
                    else
                        break;
                }
                else
                    ++nums;
            }
            nums = 0;
            //if (ip[7] == null)
            {
                for (int r = 7, j = s.Length - 1; j >= 0; --j)
                {
                    if (ip[r] != null)
                        break;
                    if (s[j] == ':')
                    {
                        if (nums > 0)
                        {
                            for (int k = j + 1; k <= j + nums; ++k)
                                ip[r] += s[k];
                            --r;
                            nums = 0;
                        }
                        else
                            break;
                    }
                    else
                        ++nums;
                }
            }
            for (int j = 0; j < 8; ++j)
            {
                if (ip[j] == null)
                    ip[j] = "";
                while (ip[j].Length < 4)
                    ip[j] = '0' + ip[j];
            }
            for (int j = 0; j < 7; ++j)
                writer.Write(ip[j]+':');
            writer.WriteLine(ip[7]);
        }
    }
    static void _316B2()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), x = int.Parse(s[1]);
        s = reader.ReadLine().Split();
        Dictionary<int, int> queue = new Dictionary<int, int>();
        LinkedList<int> undef = new LinkedList<int>();
        for (int i = 1; i <= n; ++i)
        {
            int h = int.Parse(s[i - 1]);
            if (h > 0)
                queue.Add(h, i);
            else
                undef.AddLast(i);
        }
        int[] lens = new int[undef.Count];
        int c = 0, index = 0;
        foreach (int v in undef)
        {
            int next = v;
            lens[c] = 1;
            while (true)
            {
                if (next == x)
                {
                    index = lens[c];
                    lens[c] = 0;
                    break;
                }
                if (queue.ContainsKey(next))
                {
                    next = queue[next];
                    ++lens[c];
                }
                else
                    break;
            }
            ++c;
        }
        bool[,] dp = new bool[2, n + 1];
        dp[0,0] = true;
        for (int i = 0; i < lens.Length; ++i)
        {
            if (lens[i] > 0)
            {
                dp[1,lens[i]] = true;
                for (int j = 1; j + lens[i] <= n; ++j)
                {
                    if (dp[0,j])
                    {
                        dp[1, j + lens[i]] = true;
                    }
                }
                for (int j = 1; j <= n; ++j)
                {
                    dp[0, j] = dp[0, j] || dp[1, j];
                    dp[1, j] = false;
                }
            }
        }
        for (int i = 0; i <= n; ++i)
            if (dp[0,i])
                writer.WriteLine(i + index);
    }
    static void _121A()
    {
        string[] lr = reader.ReadLine().Split();
        long l = long.Parse(lr[0]), r = long.Parse(lr[1]);
        SortedSet<long> set = new SortedSet<long>();
        set.Add(4);
        set.Add(7);
        for (long p = 10; p <= 1000000000; p *= 10)
        {
            SortedSet<long> s = new SortedSet<long>(set);
            foreach (long e in s)
            {
                if (e / (p / 10) > 0)
                {
                    set.Add(e + p * 4);
                    set.Add(e + p * 7);
                }
            }
        }
        while (set.ElementAt(0) < l)
            set.Remove(set.ElementAt(0));
        long max = set.Max;
        while (set.Max > r)
        {
            max = set.Max;
            set.Remove(set.Max);
        }
        if (set.Max < r)
            set.Add(max);
        else
            max = set.Max;
        long[] happy = new long[set.Count];
        long c = 0;
        foreach (long e in set)
            happy[c++] = e;
        long min = set.Min;
        long sum = 0;
        if (happy.Length == 1)
            sum = (r - l + 1) * happy[0];
        else
            sum = min * (min - l + 1);// +max * (max - r + 1);
        for (long i = 1; i < happy.Length; ++i)
            sum += (Math.Min(r,happy[i]) - happy[i - 1]) * happy[i];
        writer.Write(sum);
    }
    static void _150A()
    {
        long q = long.Parse(reader.ReadLine());
        //List<long> primes = new List<long>();
        bool[] notprime = new bool[q + 1];
        notprime[0] = notprime[1] = true;

        long r = 2;
        for (long i = 2; i * i <= q; ++i, ++r)
            if (!notprime[i])
            {
                //primes.Add(i);
                for (long j = i * i; j <= q; j += i)
                    notprime[j] = true;
            }
        /*for (long i = r; i <= q; ++i)
            if (!notprime[i])
                primes.Add(i);*/

        if (q == 1 || !notprime[q])
        {
            writer.WriteLine(1);
            writer.Write(0);
            return;
        }
        int multipliers = 0;
        long x = q, p1 = 0, p2 = 0;
        for (int i = 2; i <= q; ++i)//foreach (int p in primes)
        {
            if (!notprime[i])
            {
                long p = i;
                while (x % p == 0)
                {
                    ++multipliers;
                    x /= p;
                    if (p1 == 0)
                        p1 = p;
                    else if (p2 == 0)
                        p2 = p;
                    if (multipliers == 3)
                    {
                        writer.WriteLine(1);
                        writer.Write(p1 * p2);
                        return;
                    }
                    if (x == 1)
                    {
                        writer.Write(2);
                        return;
                    }
                }
            }
        }
    }
    static void _297B()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), k = int.Parse(s[2]);

        string ans = "", yes = "YES", no = "NO";
        if (n > m)
            ans = yes;
        else
        {
            s = reader.ReadLine().Split();
            Dictionary<int, int> alice = new Dictionary<int, int>(), robert = new Dictionary<int, int>();
            //int[] alice = new int[k+1], robert = new int[k+1];
            for (int i = 0; i < n; ++i)
            {
                int t = int.Parse(s[i]);
                if (alice.ContainsKey(t))
                    ++alice[t];
                else
                    alice.Add(t, 1);
            }
            s = reader.ReadLine().Split();
            int acount = n, rcount = m;
            for (int i = 0; i < m; ++i)
            {
                int t = int.Parse(s[i]);
                if (alice.ContainsKey(t) && alice[t] > 0)
                {
                    --alice[t];
                    --acount;
                }
                else
                {
                    if (robert.ContainsKey(t))
                        ++robert[t];
                    else
                        robert.Add(t, 1);
                }
            }
            rcount -= n - acount;
            int[] a = new int[acount], r = new int[rcount];
            int ac = 0;
            foreach (var v in alice)
                for (int i = 0; i < v.Value; ++i)
                    a[ac++] = v.Key;
            /*for (int i = 1; i <= k; ++i)
                for (int j = 0; j < alice[i]; ++j)
                    a[ac++] = i;*/
            int rc = 0;
            /*for (int i = 1; i <= k; ++i)
                for (int j = 0; j < robert[i]; ++j)
                    r[rc++] = i;*/
            foreach (var v in robert)
                for (int i = 0; i < v.Value; ++i)
                    r[rc++] = v.Key;
            int d = m - n;
            for (int i = rcount - 1; i >= d; --i)
                if (a[i - d] > r[i])
                {
                    ans = yes;
                    break;
                }
            if (ans == "")
                ans = no;
        }
        writer.Write(ans);
    }
    static void Main(string[] args)
    {
        //_235A();
        //_106C();
        //_300C();
        //_250B();
        //_316B2();
        //_121A();
        //_150A();
        _297B();
        reader.Close();
        writer.Close();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
//using System.Collections;
//using System.Collections.Specialized;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        if (a < b)
        {
            long t = a;
            a = b;
            b = t;
        }
        return (b > 0) ? gcd(b, a % b) : a;
    }
    static void _235A()
    {
        long n = long.Parse(reader.ReadLine()), ans = n * (n - 1);
        if (n < 3)
            ans = n;
        else if (n % 2 == 1)
            ans *= n - 2;
        else
        {
            long t = (n - 2) / 2;
            for (long i = n - 3; i > (n - 2) / 2; --i)
            {
                long g = gcd(n, i);
                if (g == 1)
                    t = Math.Max(t, i);
            }
            ans *= t;
        }
        writer.Write(Math.Max(ans, (n - 1) * (n - 2) * (n - 3)));
    }
    static void _106C()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), c0 = int.Parse(s[2]), d0 = int.Parse(s[3]);
        int[] a = new int[m + 1], b = new int[m + 1], c = new int[m + 1], d = new int[m + 1];
        for (int i = 1; i <= m; ++i)
        {
            s = reader.ReadLine().Split();
            a[i] = int.Parse(s[0]);
            b[i] = int.Parse(s[1]);
            c[i] = int.Parse(s[2]);
            d[i] = int.Parse(s[3]);
        }
        int[,] dp = new int[m + 1, n + 1];
        for (int i = 1; i * c0 <= n; ++i)
            dp[0, i * c0] = i * d0;
        for (int i = 1; i <= m; ++i)
        {
            for (int j = 1; j <= n; ++j)
            {
                if (j < c[i])
                    dp[i, j] = dp[i - 1, j];
                else
                {
                    for (int k = 0; k * b[i] <= a[i]; ++k)
                    {
                        int t = c[i] * k;
                        if (t <= j)
                            dp[i, j] = Math.Max(d[i] * k + dp[i - 1, j - t], dp[i, j]);
                    }
                }
                dp[i, j] = Math.Max(dp[i, j - 1], dp[i, j]);
            }
        }
        writer.Write(dp[m, n]);
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) != 0)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _300C()
    {
        string[] s = reader.ReadLine().Split();
        long a = long.Parse(s[0]), b = long.Parse(s[1]), n = long.Parse(s[2]);
        if (a > b)
        {
            long t = a;
            a = b;
            b = t;
        }
        long[] fact = new long[n + 1];
        fact[0] = fact[1] = 1;
        long mod = 1000000007;
        for (long i = 2; i <= n; ++i)
            fact[i] = fact[i - 1] * i % mod;
        long an = n, bn = 0;
        long ans = 0;
        while (an >= 0)
        {
            long num = an * a + bn * b;
            bool ok = true;
            for (long p = 10; ok && p <= 10000000; p *= 10)
            {
                long t = num % p / (p / 10);
                if (t != a && t != b && (t != 0 || p <= num))
                    ok = false;
            }
            if (ok)
            {
                long c = (((fact[n] * pow(fact[an], mod - 2, mod)) % mod) * pow(fact[bn], mod - 2, mod)) % mod;
                ans += c;
                ans %= mod;
            }
            --an;
            ++bn;
        }
        writer.Write(ans);
    }
    static void _250B()
    {
        string s = reader.ReadLine();
        int n = int.Parse(s);
        for (int i = 0; i < n; ++i)
        {
            s = reader.ReadLine();
            string[] ip = new string[8];
            int nums = 0;
            for (int l = 0, j = 0; j < s.Length; ++j)
            {
                if (s[j] == ':')
                {
                    if (nums > 0)
                    {
                        //ip[l] = "";
                        for (int k = j - nums; k < j; ++k)
                            ip[l] += s[k];
                        ++l;
                        nums = 0;
                    }
                    else
                        break;
                }
                else
                    ++nums;
            }
            nums = 0;
            //if (ip[7] == null)
            {
                for (int r = 7, j = s.Length - 1; j >= 0; --j)
                {
                    if (ip[r] != null)
                        break;
                    if (s[j] == ':')
                    {
                        if (nums > 0)
                        {
                            for (int k = j + 1; k <= j + nums; ++k)
                                ip[r] += s[k];
                            --r;
                            nums = 0;
                        }
                        else
                            break;
                    }
                    else
                        ++nums;
                }
            }
            for (int j = 0; j < 8; ++j)
            {
                if (ip[j] == null)
                    ip[j] = "";
                while (ip[j].Length < 4)
                    ip[j] = '0' + ip[j];
            }
            for (int j = 0; j < 7; ++j)
                writer.Write(ip[j]+':');
            writer.WriteLine(ip[7]);
        }
    }
    static void _316B2()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), x = int.Parse(s[1]);
        s = reader.ReadLine().Split();
        Dictionary<int, int> queue = new Dictionary<int, int>();
        LinkedList<int> undef = new LinkedList<int>();
        for (int i = 1; i <= n; ++i)
        {
            int h = int.Parse(s[i - 1]);
            if (h > 0)
                queue.Add(h, i);
            else
                undef.AddLast(i);
        }
        int[] lens = new int[undef.Count];
        int c = 0, index = 0;
        foreach (int v in undef)
        {
            int next = v;
            lens[c] = 1;
            while (true)
            {
                if (next == x)
                {
                    index = lens[c];
                    lens[c] = 0;
                    break;
                }
                if (queue.ContainsKey(next))
                {
                    next = queue[next];
                    ++lens[c];
                }
                else
                    break;
            }
            ++c;
        }
        bool[,] dp = new bool[2, n + 1];
        dp[0,0] = true;
        for (int i = 0; i < lens.Length; ++i)
        {
            if (lens[i] > 0)
            {
                dp[1,lens[i]] = true;
                for (int j = 1; j + lens[i] <= n; ++j)
                {
                    if (dp[0,j])
                    {
                        dp[1, j + lens[i]] = true;
                    }
                }
                for (int j = 1; j <= n; ++j)
                {
                    dp[0, j] = dp[0, j] || dp[1, j];
                    dp[1, j] = false;
                }
            }
        }
        for (int i = 0; i <= n; ++i)
            if (dp[0,i])
                writer.WriteLine(i + index);
    }
    static void _121A()
    {
        string[] lr = reader.ReadLine().Split();
        long l = long.Parse(lr[0]), r = long.Parse(lr[1]);
        SortedSet<long> set = new SortedSet<long>();
        set.Add(4);
        set.Add(7);
        for (long p = 10; p <= 1000000000; p *= 10)
        {
            SortedSet<long> s = new SortedSet<long>(set);
            foreach (long e in s)
            {
                if (e / (p / 10) > 0)
                {
                    set.Add(e + p * 4);
                    set.Add(e + p * 7);
                }
            }
        }
        while (set.ElementAt(0) < l)
            set.Remove(set.ElementAt(0));
        long max = set.Max;
        while (set.Max > r)
        {
            max = set.Max;
            set.Remove(set.Max);
        }
        if (set.Max < r)
            set.Add(max);
        else
            max = set.Max;
        long[] happy = new long[set.Count];
        long c = 0;
        foreach (long e in set)
            happy[c++] = e;
        long min = set.Min;
        long sum = 0;
        if (happy.Length == 1)
            sum = (r - l + 1) * happy[0];
        else
            sum = min * (min - l + 1);// +max * (max - r + 1);
        for (long i = 1; i < happy.Length; ++i)
            sum += (Math.Min(r,happy[i]) - happy[i - 1]) * happy[i];
        writer.Write(sum);
    }
    static void _150A()
    {
        long q = long.Parse(reader.ReadLine());
        //List<long> primes = new List<long>();
        bool[] notprime = new bool[q + 1];
        notprime[0] = notprime[1] = true;

        long r = 2;
        for (long i = 2; i * i <= q; ++i, ++r)
            if (!notprime[i])
            {
                //primes.Add(i);
                for (long j = i * i; j <= q; j += i)
                    notprime[j] = true;
            }
        /*for (long i = r; i <= q; ++i)
            if (!notprime[i])
                primes.Add(i);*/

        if (q == 1 || !notprime[q])
        {
            writer.WriteLine(1);
            writer.Write(0);
            return;
        }
        int multipliers = 0;
        long x = q, p1 = 0, p2 = 0;
        for (int i = 2; i <= q; ++i)//foreach (int p in primes)
        {
            if (!notprime[i])
            {
                long p = i;
                while (x % p == 0)
                {
                    ++multipliers;
                    x /= p;
                    if (p1 == 0)
                        p1 = p;
                    else if (p2 == 0)
                        p2 = p;
                    if (multipliers == 3)
                    {
                        writer.WriteLine(1);
                        writer.Write(p1 * p2);
                        return;
                    }
                    if (x == 1)
                    {
                        writer.Write(2);
                        return;
                    }
                }
            }
        }
    }
    static void _297B()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), k = int.Parse(s[2]);

        string ans = "", yes = "YES", no = "NO";
        if (n > m)
            ans = yes;
        else
        {
            s = reader.ReadLine().Split();
            int[] alice = new int[k+1], robert = new int[k+1];
            for (int i = 0; i < n; ++i)
                ++alice[int.Parse(s[i])];
            s = reader.ReadLine().Split();
            int acount = n, rcount = m;
            for (int i = 0; i < m; ++i)
            {
                int t = int.Parse(s[i]);
                if (alice[t] > 0)
                {
                    --alice[t];
                    --acount;
                }
                else
                    ++robert[t];
            }
            rcount -= n - acount;
            int[] a = new int[acount], r = new int[rcount];
            int ac = 0;
            for (int i = 1; i <= k; ++i)
                for (int j = 0; j < alice[i]; ++j)
                    a[ac++] = i;
            int rc = 0;
            for (int i = 1; i <= k; ++i)
                for (int j = 0; j < robert[i]; ++j)
                    r[rc++] = i;
            int d = m - n;
            for (int i = rcount - 1; i >= d; --i)
                if (a[i - d] > r[i])
                {
                    ans = yes;
                    break;
                }
            if (ans == "")
                ans = no;
        }
        writer.Write(ans);
    }
    static void Main(string[] args)
    {
        //_235A();
        //_106C();
        //_300C();
        //_250B();
        //_316B2();
        //_121A();
        //_150A();
        _297B();
        reader.Close();
        writer.Close();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
//using System.Collections;
//using System.Collections.Specialized;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        if (a < b)
        {
            long t = a;
            a = b;
            b = t;
        }
        return (b > 0) ? gcd(b, a % b) : a;
    }
    static void _235A()
    {
        long n = long.Parse(reader.ReadLine()), ans = n * (n - 1);
        if (n < 3)
            ans = n;
        else if (n % 2 == 1)
            ans *= n - 2;
        else
        {
            long t = (n - 2) / 2;
            for (long i = n - 3; i > (n - 2) / 2; --i)
            {
                long g = gcd(n, i);
                if (g == 1)
                    t = Math.Max(t, i);
            }
            ans *= t;
        }
        writer.Write(Math.Max(ans, (n - 1) * (n - 2) * (n - 3)));
    }
    static void _106C()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), c0 = int.Parse(s[2]), d0 = int.Parse(s[3]);
        int[] a = new int[m + 1], b = new int[m + 1], c = new int[m + 1], d = new int[m + 1];
        for (int i = 1; i <= m; ++i)
        {
            s = reader.ReadLine().Split();
            a[i] = int.Parse(s[0]);
            b[i] = int.Parse(s[1]);
            c[i] = int.Parse(s[2]);
            d[i] = int.Parse(s[3]);
        }
        int[,] dp = new int[m + 1, n + 1];
        for (int i = 1; i * c0 <= n; ++i)
            dp[0, i * c0] = i * d0;
        for (int i = 1; i <= m; ++i)
        {
            for (int j = 1; j <= n; ++j)
            {
                if (j < c[i])
                    dp[i, j] = dp[i - 1, j];
                else
                {
                    for (int k = 0; k * b[i] <= a[i]; ++k)
                    {
                        int t = c[i] * k;
                        if (t <= j)
                            dp[i, j] = Math.Max(d[i] * k + dp[i - 1, j - t], dp[i, j]);
                    }
                }
                dp[i, j] = Math.Max(dp[i, j - 1], dp[i, j]);
            }
        }
        writer.Write(dp[m, n]);
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) != 0)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _300C()
    {
        string[] s = reader.ReadLine().Split();
        long a = long.Parse(s[0]), b = long.Parse(s[1]), n = long.Parse(s[2]);
        if (a > b)
        {
            long t = a;
            a = b;
            b = t;
        }
        long[] fact = new long[n + 1];
        fact[0] = fact[1] = 1;
        long mod = 1000000007;
        for (long i = 2; i <= n; ++i)
            fact[i] = fact[i - 1] * i % mod;
        long an = n, bn = 0;
        long ans = 0;
        while (an >= 0)
        {
            long num = an * a + bn * b;
            bool ok = true;
            for (long p = 10; ok && p <= 10000000; p *= 10)
            {
                long t = num % p / (p / 10);
                if (t != a && t != b && (t != 0 || p <= num))
                    ok = false;
            }
            if (ok)
            {
                long c = (((fact[n] * pow(fact[an], mod - 2, mod)) % mod) * pow(fact[bn], mod - 2, mod)) % mod;
                ans += c;
                ans %= mod;
            }
            --an;
            ++bn;
        }
        writer.Write(ans);
    }
    static void _250B()
    {
        string s = reader.ReadLine();
        int n = int.Parse(s);
        for (int i = 0; i < n; ++i)
        {
            s = reader.ReadLine();
            string[] ip = new string[8];
            int nums = 0;
            for (int l = 0, j = 0; j < s.Length; ++j)
            {
                if (s[j] == ':')
                {
                    if (nums > 0)
                    {
                        //ip[l] = "";
                        for (int k = j - nums; k < j; ++k)
                            ip[l] += s[k];
                        ++l;
                        nums = 0;
                    }
                    else
                        break;
                }
                else
                    ++nums;
            }
            nums = 0;
            //if (ip[7] == null)
            {
                for (int r = 7, j = s.Length - 1; j >= 0; --j)
                {
                    if (ip[r] != null)
                        break;
                    if (s[j] == ':')
                    {
                        if (nums > 0)
                        {
                            for (int k = j + 1; k <= j + nums; ++k)
                                ip[r] += s[k];
                            --r;
                            nums = 0;
                        }
                        else
                            break;
                    }
                    else
                        ++nums;
                }
            }
            for (int j = 0; j < 8; ++j)
            {
                if (ip[j] == null)
                    ip[j] = "";
                while (ip[j].Length < 4)
                    ip[j] = '0' + ip[j];
            }
            for (int j = 0; j < 7; ++j)
                writer.Write(ip[j]+':');
            writer.WriteLine(ip[7]);
        }
    }
    static void _316B2()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), x = int.Parse(s[1]);
        s = reader.ReadLine().Split();
        Dictionary<int, int> queue = new Dictionary<int, int>();
        LinkedList<int> undef = new LinkedList<int>();
        for (int i = 1; i <= n; ++i)
        {
            int h = int.Parse(s[i - 1]);
            if (h > 0)
                queue.Add(h, i);
            else
                undef.AddLast(i);
        }
        int[] lens = new int[undef.Count];
        int c = 0, index = 0;
        foreach (int v in undef)
        {
            int next = v;
            lens[c] = 1;
            while (true)
            {
                if (next == x)
                {
                    index = lens[c];
                    lens[c] = 0;
                    break;
                }
                if (queue.ContainsKey(next))
                {
                    next = queue[next];
                    ++lens[c];
                }
                else
                    break;
            }
            ++c;
        }
        bool[,] dp = new bool[2, n + 1];
        dp[0,0] = true;
        for (int i = 0; i < lens.Length; ++i)
        {
            if (lens[i] > 0)
            {
                dp[1,lens[i]] = true;
                for (int j = 1; j + lens[i] <= n; ++j)
                {
                    if (dp[0,j])
                    {
                        dp[1, j + lens[i]] = true;
                    }
                }
                for (int j = 1; j <= n; ++j)
                {
                    dp[0, j] = dp[0, j] || dp[1, j];
                    dp[1, j] = false;
                }
            }
        }
        for (int i = 0; i <= n; ++i)
            if (dp[0,i])
                writer.WriteLine(i + index);
    }
    static void _121A()
    {
        string[] lr = reader.ReadLine().Split();
        long l = long.Parse(lr[0]), r = long.Parse(lr[1]);
        SortedSet<long> set = new SortedSet<long>();
        set.Add(4);
        set.Add(7);
        for (long p = 10; p <= 1000000000; p *= 10)
        {
            SortedSet<long> s = new SortedSet<long>(set);
            foreach (long e in s)
            {
                if (e / (p / 10) > 0)
                {
                    set.Add(e + p * 4);
                    set.Add(e + p * 7);
                }
            }
        }
        while (set.ElementAt(0) < l)
            set.Remove(set.ElementAt(0));
        long max = set.Max;
        while (set.Max > r)
        {
            max = set.Max;
            set.Remove(set.Max);
        }
        if (set.Max < r)
            set.Add(max);
        else
            max = set.Max;
        long[] happy = new long[set.Count];
        long c = 0;
        foreach (long e in set)
            happy[c++] = e;
        long min = set.Min;
        long sum = 0;
        if (happy.Length == 1)
            sum = (r - l + 1) * happy[0];
        else
            sum = min * (min - l + 1);// +max * (max - r + 1);
        for (long i = 1; i < happy.Length; ++i)
            sum += (Math.Min(r,happy[i]) - happy[i - 1]) * happy[i];
        writer.Write(sum);
    }
    static void _150A()
    {
        long q = long.Parse(reader.ReadLine());
        //List<long> primes = new List<long>();
        bool[] notprime = new bool[q + 1];
        notprime[0] = notprime[1] = true;

        long r = 2;
        for (long i = 2; i * i <= q; ++i, ++r)
            if (!notprime[i])
            {
                //primes.Add(i);
                for (long j = i * i; j <= q; j += i)
                    notprime[j] = true;
            }
        /*for (long i = r; i <= q; ++i)
            if (!notprime[i])
                primes.Add(i);*/

        if (q == 1 || !notprime[q])
        {
            writer.WriteLine(1);
            writer.Write(0);
            return;
        }
        int multipliers = 0;
        long x = q, p1 = 0, p2 = 0;
        for (int i = 2; i <= q; ++i)//foreach (int p in primes)
        {
            if (!notprime[i])
            {
                long p = i;
                while (x % p == 0)
                {
                    ++multipliers;
                    x /= p;
                    if (p1 == 0)
                        p1 = p;
                    else if (p2 == 0)
                        p2 = p;
                    if (multipliers == 3)
                    {
                        writer.WriteLine(1);
                        writer.Write(p1 * p2);
                        return;
                    }
                    if (x == 1)
                    {
                        writer.Write(2);
                        return;
                    }
                }
            }
        }
    }
    static void _297B()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), k = int.Parse(s[2]);

        string ans = "", yes = "YES", no = "NO";
        if (n > m)
            ans = yes;
        else
        {
            s = reader.ReadLine().Split();
            SortedDictionary<int, int> alice = new SortedDictionary<int, int>(), robert = new SortedDictionary<int, int>();
            //int[] alice = new int[k+1], robert = new int[k+1];
            for (int i = 0; i < n; ++i)
            {
                int t = int.Parse(s[i]);
                if (alice.ContainsKey(t))
                    ++alice[t];
                else
                    alice.Add(t, 1);
            }
            s = reader.ReadLine().Split();
            int acount = n, rcount = m;
            for (int i = 0; i < m; ++i)
            {
                int t = int.Parse(s[i]);
                if (alice.ContainsKey(t) && alice[t] > 0)
                {
                    --alice[t];
                    --acount;
                }
                else
                {
                    if (robert.ContainsKey(t))
                        ++robert[t];
                    else
                        robert.Add(t, 1);
                }
            }
            rcount -= n - acount;
            int[] a = new int[acount], r = new int[rcount];
            int ac = 0;
            foreach (var v in alice)
                for (int i = 0; i < v.Value; ++i)
                    a[ac++] = v.Key;
            /*for (int i = 1; i <= k; ++i)
                for (int j = 0; j < alice[i]; ++j)
                    a[ac++] = i;*/
            int rc = 0;
            /*for (int i = 1; i <= k; ++i)
                for (int j = 0; j < robert[i]; ++j)
                    r[rc++] = i;*/
            foreach (var v in robert)
                for (int i = 0; i < v.Value; ++i)
                    r[rc++] = v.Key;
            int d = m - n;
            for (int i = rcount - 1; i >= d; --i)
                if (a[i - d] > r[i])
                {
                    ans = yes;
                    break;
                }
            if (ans == "")
                ans = no;
        }
        writer.Write(ans);
    }
    static void Main(string[] args)
    {
        //_235A();
        //_106C();
        //_300C();
        //_250B();
        //_316B2();
        //_121A();
        //_150A();
        _297B();
        reader.Close();
        writer.Close();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n, m;
            n = int.Parse(s[0]);
            m = int.Parse(s[1]);
            s = Console.ReadLine().Split(' ');
            int[] pescin = new int[n];
            for (int i = 0; i < n; i++)
            {
                pescin[i] = int.Parse(s[i]);
            }
            s = Console.ReadLine().Split(' ');
            int[] pescim = new int[m];
            for (int i = 0; i < m; i++)
            {
                pescim[i] = int.Parse(s[i]);
            }
            Array.Sort(pescin);
            Array.Sort(pescim);
            if (pescin.Length > pescim.Length)
            {

                Console.WriteLine("YES");
                return;
            }
            if (pescin[n - 1] > pescim[m - 1])
            {
                Console.WriteLine("YES");
                return;
            }
            int g = m - n;
            for (int i = 0; i < n; i++)
            {
                if (pescim[i + g] < pescin[i])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }

    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Collections;
using System.Text.RegularExpressions;

namespace Task
{

    #region MyIo

    internal class MyIo : IDisposable
    {
#if  LOCAL_TEST
        private readonly TextReader inputStream = new StreamReader("input.txt");
#else
        private readonly TextReader inputStream = Console.In;
#endif
#if  FBHC_TEST
        private readonly TextWriter outputStream = new StreamWriter("output.txt");
#else
        private readonly TextWriter outputStream = Console.Out;
#endif

        private string[] tokens;
        private int pointer;

        public char NextChar()
        {
            try
            {
                var c = inputStream.Read();

                if (c < 0)
                    c = 0;

                return (char)c;
            }
            catch (IOException)
            {
                return '\0';
            }
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = (NextLine() + string.Empty).Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return Next<int>();
        }

        public long NextLong()
        {
            return Next<long>();
        }

        public T Next<T>()
        {
            var t = typeof(T);

            if (t == typeof(char))
                return (T)(object)NextChar();

            object s = NextString();

            if (t == typeof(string))
                return (T)s;

            return (T)Convert.ChangeType(s, typeof(T));
        }

        public IEnumerable<T> NextWhile<T>(Predicate<T> pred)
        {
            if (pred == null)
                yield break;

            var res = Next<T>();

            while (pred(res))
            {
                yield return res;

                res = Next<T>();
            }
        }

        public IEnumerable<T> NextSeq<T>(long n)
        {
            for (var i = 0; i < n; i++)
                yield return Next<T>();
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));
        }

        public void PrintLine(string format, params object[] args)
        {
            Print(format, args);

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "YES" : "NO");
        }

        public void PrintLine(bool o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Print<T>(T o)
        {
            var ienum = o as IEnumerable;

            if (ienum != null && typeof(T) != typeof(string))
            {
                var first = true;

                foreach (var iev in ienum)
                {
                    if (!first && iev != null)
                        Print(" ");

                    Print(iev);

                    first = false;
                }

            }
            else
            {
                outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));
            }

        }

        public void PrintLine<T>(T o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }

    public static class ListExtensions
    {
        public static void Each<T>(this IEnumerable<T> self, Action<T> action)
        {
            foreach (var v in self)
                action(v);
        }

        public static string Reverse(this string s)
        {
            var charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        public static IEnumerable<T> ToCycleEnumerable<T>(this IEnumerable<T> self)
        {
            if (self != null)
            {
                for (; ; )
                {
                    foreach (var x in self)
                        yield return x;
                }
            }
        }

        public static T CycleGet<T>(this IList<T> self, int index)
        {
            var c = self.Count;
            return self[(index % c + c) % c];
        }

        public static IList<T> Shuffle<T>(this IList<T> self)
        {
            var rnd = new Random(DateTime.Now.Millisecond);

            var n = self.Count;

            while (n > 1)
            {
                n--;
                var k = rnd.Next(n + 1);
                var value = self[k];
                self[k] = self[n];
                self[n] = value;
            }

            return self;
        }

        public static IList<IList<T>> UseForNew2D<T>(this T def, int fd, int sd)
        {
            var fdim = new T[fd][];

            for (int i = 0; i < fd; i++)
            {
                fdim[i] = new T[sd];
                Fill(fdim[i], def);
            }

            return fdim;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<int, IList<T>, T> fval)
        {
            for (var i = 0; i < self.Count; i++)
                self[i] = fval(i, self);

            return self;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<int, T> fval)
        {
            return self.Fill((x, slf) => fval(x));
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<T> fval)
        {
            return self.Fill(x => fval());
        }

        public static IList<T> Fill<T>(this IList<T> self, T val)
        {
            return self.Fill(() => val);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long> val = null)
        {
            return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long, long> val)
        {
            return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));
        }

        public static long HashOne<T>(this T self, long current)
        {
            return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));
        }

        public static IList<T1> BuildSegTree<T1, T2>(this IList<T2> a, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            var t = new T1[a.Count << 2];

            a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);

            return t;
        }

        private static void BuildSegTree<T1, T2>(this IList<T2> a, IList<T1> t, int v, int tl, int tr, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            if (tl == tr)
            {
                t[v] = convert(a[tl]);
            }
            else
            {
                int tm = (tl + tr) >> 1;

                BuildSegTree(a, t, v << 1, tl, tm, combine, convert);
                BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);

                t[v] = combine(t[v << 1], t[(v << 1) + 1]);
            }
        }
    }

    public static class P
    {
        public static P<T1, T2> Create<T1, T2>(T1 key, T2 val)
        {
            return new P<T1, T2>(key, val);
        }
    }

    public class P<T1, T2>
    {
        private class PComparer : IComparer<P<T1, T2>>
        {
            private readonly bool? byKey;

            public PComparer(bool? byKey)
            {
                this.byKey = byKey;
            }

            public int Compare(P<T1, T2> x, P<T1, T2> y)
            {
                x = x ?? new P<T1, T2>();
                y = y ?? new P<T1, T2>();

                if (byKey == true)
                    return Comparer<T1>.Default.Compare(x.Key, y.Key);
                else if (byKey == false)
                    return Comparer<T2>.Default.Compare(x.Value, y.Value);
                else
                {
                    var tr = Comparer<T1>.Default.Compare(x.Key, y.Key);

                    if (tr != 0)
                        tr = Comparer<T2>.Default.Compare(x.Value, y.Value);

                    return tr;
                }
            }
        }

        public P()
        {
        }

        public P(T1 key, T2 val)
        {
            this.Key = key;
            this.Value = val;
        }

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

        public P<T1, T2> Clone()
        {
            return new P<T1, T2>(Key, Value);
        }

        public static IComparer<P<T1, T2>> KeyComparer
        {
            get { return new PComparer(true); }
        }

        public static IComparer<P<T1, T2>> ValueComparer
        {
            get { return new PComparer(false); }
        }

        public static implicit operator T1(P<T1, T2> obj)
        {
            return obj.Key;
        }

        public static implicit operator T2(P<T1, T2> obj)
        {
            return obj.Value;
        }

        public P<T1, T2> SetKey(T1 key)
        {
            Key = key;
            return this;
        }

        public P<T1, T2> SetValue(T2 value)
        {
            Value = value;
            return this;
        }

        public override string ToString()
        {
            return string.Format("Key: {0}, Value: {1}", Key, Value);
        }

        public override bool Equals(object obj)
        {
            var co = obj as P<T1, T2>;

            return co != null && co.GetHashCode() == GetHashCode();
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = unchecked(hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode()));
            hash = unchecked(hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode()));
            return hash;

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        public static void Main(string[] args)
        {
            using (MyIo io = new MyIo())
            {
                new Program(io)
                    .Solve();
            }
        }

        #endregion

        private void Solve()
        {
            var n = io.NextInt();
            var m = io.NextInt();
            var k = io.NextInt();

            var rba = io.NextSeq<int>(n).ToArray().Shuffle().OrderBy(x => x).ToArray();

            var rbb = io.NextSeq<int>(m).ToArray().Shuffle().OrderBy(x => x).Skip(Math.Max(0, m - n)).ToArray();

            var res = true;

            if (n <= m)
            {
                res = false;

                for (int j = 0; j < n; j++)
                {
                    if (rba[j] > rbb[j])
                    {
                        res = true;
                        break;
                    }
                }
            }

            io.PrintLine(res);

        }

    }

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);

	int n, m, k;
	cin >> n >> m >> k;

	vector<int> A(n);
	vector<int> R(m);

	for (int i = 0; i < n; i++) cin >> A[i];
	for (int i = 0; i < m; i++) cin >> R[i];

	sort(A.begin(), A.end());
	sort(R.begin(), R.end());

	int i = A.size(); int j = R.size();
	while (i > 0 && j > 0)
	{
		i--; j--;
		if (A[i] > R[j])
		{
			cout << "YES\n";
			exit(0);
		}
	}

	if (i > 0) cout << "YES\n";
	cout << "NO\n";

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);

	int n, m, k;
	cin >> n >> m >> k;

	vector<int> A(n);
	vector<int> R(m);

	for (int i = 0; i < n; i++) cin >> A[i];
	for (int i = 0; i < m; i++) cin >> R[i];

	sort(A.begin(), A.end());
	sort(R.begin(), R.end());

	int i = A.size(); int j = R.size();
	while (i > 0 && j > 0)
	{
		i--; j--;
		if (A[i] > R[j])
		{
			cout << "YES\n";
			exit(0);
		}
	}

	if (i > 0) cout << "YES\n";
	else cout << "NO\n";

}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rev(i, n) for(int i = (n) - 1; i >= 0; --i)
using namespace std;

void bug() { cout << " " << endl; }
template<class T> void bug(T a) { cout << a << "  "; }
template<class T> void bug(T* a, int n) {rep(i, n) bug(a[i]);}

int n, m, k;
map<int,int> mp;

int main() {
    cin >> n >> m >> k;
    rep(i, n) {
        int x; cin >> x;
        mp[x] ++;
    }
    rep(i, m) {
        int x; cin >> x;
        mp[x] --;
    }

    vector<int> v;
    for(map<int,int>::iterator it = mp.begin(); it != mp.end(); it++)
        if(it->second != 0) v.push_back(it->second);

    int t = 0;
    rev(i, v.size()) {
        t += v[i];
        if(t > 0) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


#include <map>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int n, m, k;
  map<int, int> c;

  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &k);
    ++c[k];
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &k);
    --c[k];
  }

  k = 0;
  for (map<int, int>::const_reverse_iterator it = c.rbegin(); it != c.rend(); ++it) {
    k += it->second;
    if (k > 0) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;

const int INF=0x3f3f3f3f;
typedef long long ll;
const int M=100005;
const int mod=1e9+7;
const double eps=1e-6;
const double Pi=2*acos(0.0);

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int bit(int x){return 1<<x;}
inline double dabs(double x){return x>0?x:(-x);}
inline int abs(int x){return x>0?x:(-x);}
inline int lowbit(int x){return x&(-x);}

int n,m,k;
int a[M],b[M];
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++) cin>>b[i];
    sort(a,a+n);
    sort(b,b+m);
    int x=n-1,y=m-1;
    bool jud=0;
    if(n>m) jud=1;
    while(x>0&&y>0&&!jud){
        if(a[x]>b[y]) jud=1;
        x--,y--;
    }
    puts(jud?"YES":"NO");
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;

const int INF=0x3f3f3f3f;
typedef long long ll;
const int M=100005;
const int mod=1e9+7;
const double eps=1e-6;
const double Pi=2*acos(0.0);

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int bit(int x){return 1<<x;}
inline double dabs(double x){return x>0?x:(-x);}
inline int abs(int x){return x>0?x:(-x);}
inline int lowbit(int x){return x&(-x);}

int n,m,k;
int a[M],b[M];
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++) cin>>b[i];
    sort(a,a+n);
    sort(b,b+m);
    int x=n-1,y=m-1;
    bool jud=0;
    if(n>m) jud=1;
    while(x>=0&&y>=0&&!jud){
        if(a[x]>b[y]) jud=1;
        x--,y--;
    }
    puts(jud?"YES":"NO");
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;

const int INF=0x3f3f3f3f;
typedef long long ll;
const int M=100005;
const int mod=1e9+7;
const double eps=1e-6;
const double Pi=2*acos(0.0);

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int bit(int x){return 1<<x;}
inline double dabs(double x){return x>0?x:(-x);}
inline int abs(int x){return x>0?x:(-x);}
inline int lowbit(int x){return x&(-x);}

int n,m,k;
int a[M],b[M];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<m;i++) cin>>b[i];
	sort(a,a+n);
	sort(b,b+m);
	int x=n-1,y=m-1,cnt=0;
	while(1){
		if(a[x]>b[y]) cnt--;
		else if(a[x]<b[y]) cnt++;
		x--;y--;
		if(cnt<0||x<0||y<0) break;
	}
	puts(cnt<0?"YES":"NO");
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;

const int INF=0x3f3f3f3f;
typedef long long ll;
const int M=100005;
const int mod=1e9+7;
const double eps=1e-6;
const double Pi=2*acos(0.0);

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int bit(int x){return 1<<x;}
inline double dabs(double x){return x>0?x:(-x);}
inline int abs(int x){return x>0?x:(-x);}
inline int lowbit(int x){return x&(-x);}

int n,m,k;
int a[M],b[M];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<m;i++) cin>>b[i];
	sort(a,a+n);
	sort(b,b+m);
	int x=n-1,y=m-1,cnt=0;
	if(n>m) cnt=-1;
	else{
		while(1){
			if(a[x]>b[y]) cnt--;
			else if(a[x]<b[y]) cnt++;
			x--;y--;
			if(cnt<0||x<0||y<0) break;
		}
	}
	puts(cnt<0?"YES":"NO");
	return 0;
}


/*
 * Package: StandardCodeLibrary.Core
 * */
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <utility>
#include <vector>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <climits>
#if __GNUC__>=4 and __GNUC_MINOR__>=6
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#endif
#ifdef  __GXX_EXPERIMENTAL_CXX0X__
#define typeof decltype
#endif
using namespace std;

#define lp for(;;)
#define repf(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repf(i,0,n)
#define ft(i,a,b) for (int i=(a);i<=(b);++i)
#define fdt(i,a,b) for (int i=(a);i>=(b);--i)
#define feach(e,s) for (typeof((s).begin()) e=(s).begin();e!=(s).end();++e)
#define fsubset(subset,set) for (int subset=(set)&((set)-1);subset;subset=(subset-1)&(set))
#define forin(i,charset) for (cstr i=(charset);*i;i++)
#define whl while
#define rtn return
#define fl(x,y) memset((x),char(y),sizeof(x))
#define clr(x) fl(x,char(0))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define pb push_back
#define mp make_pair
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define rnk order_of_key
#define sel find_by_order
#define x first
#define y second
#define sz(x) (int((x).size()))
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define uniq(x) srt(x),(x).erase(unique(all(x)),(x).end())
#define rev(x) reverse(all(x))
#define vec vector
#define pr pair
#define que queue
#define prq priority_queue
#define itr iterator
#define sf scanf
#define pf printf
#define pdb(prcs,x) (cout<<setprecision(prcs)<<fixed<<(sgn(x)?(x):0))
#ifdef DEBUG
#define prt(x) cerr<<#x"="<<(x)<<endl
#define asrtWA(s) do if(!(s))do{cerr<<"assert("#s")"<<endl;}whl(0);whl(0)
#define asrtTLE(s) do if(!(s))do{cerr<<"assert("#s")"<<endl;}whl(0);whl(0)
#define asrtMLE(s) do if(!(s))do{cerr<<"assert("#s")"<<endl;}whl(0);whl(0)
#define asrtOLE(s) do if(!(s))do{cerr<<"assert("#s")"<<endl;}whl(0);whl(0)
#define asrtRE(s) do if(!(s))do{cerr<<"assert("#s")"<<endl;}whl(0);whl(0)
#define runtime() cerr<<"Used: "<<db(clock())/CLOCKS_PER_SEC<<"s"<<endl
#define input(in) do{}whl(0)
#define output(out) do{}whl(0)
#else
#define endl (char('\n'))
#define prt(x) (cerr)
#define asrtWA(s) do if(!(s))exit(0);whl(0)
#define asrtTLE(s) do if(!(s))whl(1);whl(0)
#define asrtMLE(s) do if(!(s))whl(new int);whl(0)
#define asrtOLE(s) do if(!(s))whl(1)puts("OLE");whl(0)
#define asrtRE(s) do if(!(s))*(int*)0=0;whl(0)
#define runtime() (cerr)
#define input(in) freopen(in,"r",stdin)
#define output(out) freopen(out,"w",stdout)
#endif

typedef long long int lli;
typedef double db;
typedef const char* cstr;
typedef string str;
typedef vec<int> vi;
typedef vec<vi> vvi;
typedef vec<bool> vb;
typedef vec<vb> vvb;
typedef vec<str> vs;
typedef pr<int,int> pii;
typedef pr<lli,lli> pll;
typedef pr<db,db> pdd;
typedef map<int,int> mii;
typedef map<str,int> msi;
typedef map<char,int> mci;
typedef set<int> si;
typedef set<str> ss;
typedef que<int> qi;
typedef vec<pii> vpii;
typedef vec<pdd> vpdd;
#if __GNUC__>=4 and __GNUC_MINOR__>=6
using __gnu_cxx::rope;
#endif
#if __GNUC__>=4 and __GNUC_MINOR__>=7
template<typename key,typename value>class ext_map:public __gnu_pbds::tree<key,value,less<key>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>{};
template<typename key>class ext_set:public __gnu_pbds::tree<key,__gnu_pbds::null_type,less<key>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>{};
#elif __GNUC__>=4 and __GNUC_MINOR__>=6
template<typename key,typename value>class ext_map:public __gnu_pbds::tree<key,value,less<key>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>{};
template<typename key>class ext_set:public __gnu_pbds::tree<key,__gnu_pbds::null_mapped_type,less<key>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>{};
#endif

int oo=(~0u)>>1;
lli ooll=(~0ull)>>1;
db inf=1e+10;
db eps=1e-10;
db gam=0.5772156649015328606;
db pi=acos(-1.0);
int dx[]={1,0,-1,0,1,-1,-1,1,0};
int dy[]={0,1,0,-1,1,1,-1,-1,0};
int MOD=1000000007;

template<typename type>inline bool cmax(type& a,const type& b){rtn a<b?a=b,true:false;}
template<typename type>inline bool cmin(type& a,const type& b){rtn b<a?a=b,true:false;}
template<typename type>inline type sqr(const type& x){rtn x*x;}
inline int sgn(const db& x){rtn (x>+eps)-(x<-eps);}
inline int dbcmp(const db& a,const db& b){rtn sgn(a-b);}
template<typename istream,typename first_type,typename second_type>inline istream& operator>>(istream& cin,pr<first_type,second_type>& x){rtn cin>>x.x>>x.y;}
template<typename ostream,typename first_type,typename second_type>inline ostream& operator<<(ostream& cout,const pr<first_type,second_type>& x){rtn cout<<x.x<<" "<<x.y;}
template<typename istream,typename type>inline istream& operator>>(istream& cin,vec<type>& x){rep(i,sz(x))cin>>x[i];rtn cin;}
template<typename ostream,typename type>inline ostream& operator<<(ostream& cout,vec<type>& x){rep(i,sz(x))cout<<x[i]<<(i+1==sz(x)?"":" ");rtn cout;}
template<typename type>inline pr<type,type> operator-(const pr<type,type>& x){rtn mp(-x.x,-x.y);}
template<typename type>inline pr<type,type> operator+(const pr<type,type>& a,const pr<type,type>& b){rtn mp(a.x+b.x,a.y+b.y);}
template<typename type>inline pr<type,type> operator-(const pr<type,type>& a,const pr<type,type>& b){rtn mp(a.x-b.x,a.y-b.y);}
template<typename type>inline pr<type,type> operator*(const pr<type,type>& a,const type& b){rtn mp(a.x*b,a.y*b);}
template<typename type>inline pr<type,type> operator/(const pr<type,type>& a,const type& b){rtn mp(a.x/b,a.y/b);}
template<typename type>inline pr<type,type>& operator-=(pr<type,type>& a,const pr<type,type>& b){rtn a=a-b;}
template<typename type>inline pr<type,type>& operator+=(pr<type,type>& a,const pr<type,type>& b){rtn a=a+b;}
template<typename type>inline pr<type,type>& operator*=(pr<type,type>& a,const type& b){rtn a=a*b;}
template<typename type>inline pr<type,type>& operator/=(pr<type,type>& a,const type& b){rtn a=a/b;}
template<typename type>inline type cross(const pr<type,type>& a,const pr<type,type>& b){rtn a.x*b.y-a.y*b.x;}
template<typename type>inline type dot(const pr<type,type>& a,const pr<type,type>& b){rtn a.x*b.x+a.y*b.y;}
template<typename type>inline type gcd(type a,type b){if(b)whl((a%=b)&&(b%=a));rtn a+b;}
template<typename type>inline type lcm(type a,type b){rtn a*b/gcd(a,b);}
template<typename type>inline void bit_inc(vec<type>& st,int x,type inc){whl(x<sz(st))st[x]+=inc,x|=x+1;}
template<typename type>inline type bit_sum(const vec<type>& st,int x){type s=0;whl(x>=0)s+=st[x],x=(x&(x+1))-1;rtn s;}
template<typename type>inline type bit_kth(const vec<type>& st,int k){int x=0,y=0,z=0;whl((1<<(++y))<=sz(st));fdt(i,y-1,0){if((x+=1<<i)>sz(st)||z+st[x-1]>k)x-=1<<i;else z+=st[x-1];}rtn x;}
inline void make_set(vi& st){rep(i,sz(st))st[i]=i;}
inline int find_set(vi& st,int x){int y=x,z;whl(y!=st[y])y=st[y];whl(x!=st[x])z=st[x],st[x]=y,x=z;rtn y;}
inline bool union_set(vi& st,int a,int b){a=find_set(st,a),b=find_set(st,b);rtn a!=b?st[a]=b,true:false;}
template<typename type>inline void merge(type& a,type& b){if(sz(a)<sz(b))swap(a,b);whl(sz(b))a.ins(*b.begin()),b.ers(b.begin());}

struct Initializer{Initializer(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}~Initializer(){runtime();}}initializer;

int cnt(str s)
{
	int ans=0;
	rep(i,sz(s)) if (s[i]=='1') ans++;
	rtn ans;
}

bool calc(str a,str b)
{
	rtn cnt(a)>=cnt(b);
}

int main()
{
//	str a,b;
//	cin>>a>>b;
//	cout<<(calc(a,b)?"YES":"NO")<<endl;
	int n,m,k;
	cin>>n>>m>>k;
	vi a(n),b(m);
	cin>>a>>b;
	vi cnt(k);
	rep(i,sz(a)) cnt[a[i]-1]++;
	rep(i,sz(b)) cnt[b[i]-1]--;
	bool ans=false;
	rep(i,k) if (cnt[i]>0) ans=true;
	cout<<(ans?"YES":"NO")<<endl;
}