#include<bits/stdc++.h>
#define maxn (200000)
#define mod (998244353)
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    return x*f;
}
long long gcd(long long x,long long y){return y?gcd(y,x%y):x;}
long long power(long x,long y)
{
	long long t=1;
	for(;y;y>>=1,x=x*x%mod)
		if(y&1)t=t*x%mod;
	return t;
}
long long a[maxn],b[maxn];
int main()
{
	int n=read();
	for(int i=0;i<n;i++)b[i]=read();
	for(int i=0;i<n;i++)if(b[i]<b[(i+1)%n])
	{
		a[(i+1)%n]=b[(i+1)%n];
		for(int j=i;j!=(i+1)%n;j=j?j-1:n-1)
		{
			a[j]=b[j]+a[(j+1)%n];
			if(a[j]<1e9)a[j]+=(1e9/a[(j+1)%n]+1)*a[(j+1)%n]+1;
		}
		cout<<"YES"<<endl;
		for(int j=0;j<n;j++)printf("%I64d ",a[j]);
		cout<<endl;
		return 0;
	}
	if(b[0]==0)
	{
		cout<<"YES"<<endl;
		for(int j=0;j<n;j++)printf("%I64d ",1);
		cout<<endl;
	}else cout<<"NO"<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
	}
	if(val[id] % val[(id+1)%n] != v[x]){
		val[(id+1)%n] *= 2;
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
	}
	for(int i = 0; i < n; i++){
		if(val[i] % val[(i+1)%n] != v[i]){
			val[(i+1)%n] *= 2;
		}
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	bool z = 0;
	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
		if(!v[x] && !z){
			val[x] *= 2;
			z = 1;
		}
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double eps = 1e-9;
const int mod = 1000000007;
const int N = 100005;

int main(){
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
const int mod = 1000000007;
const int N = 200005;

int val[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(v[i], v[(i-1+n) % n]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
	}
	for(int i = 0; i < n; i++){
		if(val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%d ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
const int mod = 1000000007;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
		if(v[x] == 0 && v[(x - 1 + n) % n])
			val[x] *= 2;
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	int nz = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		nz |= v[i] != 0;
	}
	if(!nz){
		printf("YES\n");
		for(int i = 0; i <n; i++){
			printf("1 ");
		}
		printf("\n");
		return 0;
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] >= val[id] && val[(i-1+n)%n] < val[i])
			id = i;
	}

	val[id] *= 2;
	bool z = 0;
	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
		z = 1;
	}
	val[id] /= 2;
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
const int mod = 1000000007;
const int N = 200005;

int val[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%d ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
const int mod = 1000000007;
const int N = 200005;

ll val[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
	}
	if(val[id] % val[(id+1)%n] != v[id]){
		val[(id+1)%n] *= 2;
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
const int mod = 1000000007;
const int N = 200005;

ll val[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
		if(v[x] == 0 && v[(x - 1 + n) % n])
			val[x] *= 2;
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	int nz = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		nz |= v[i] != 0;
	}
	if(!nz){
		printf("YES\n");
		for(int i = 0; i <n; i++){
			printf("1 ");
		}
		printf("\n");
		return 0;
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] =  v[i];
		if(val[i] >= val[id] && val[(i-1+n)%n] < val[i])
			id = i;
	}

	val[id] *= 2;
	bool z = 0;
	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
		z = 1;
	}
	val[id] /= 2;
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
		if(v[x] == 0 && v[(x - 1 + n) % n])
			val[x] *= 2;
		if(val[x] > mod){
			val[x] = v[x];
		}
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	int nz = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		nz |= v[i] != 0;
	}
	if(!nz){
		printf("YES\n");
		for(int i = 0; i <n; i++){
			printf("1 ");
		}
		printf("\n");
		return 0;
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	bool z = 0;
	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
		if(!v[x] && !z){
			val[x] *= 2;
			z = 1;
		}
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
const int mod = 1000000007;
const int N = 200005;

int val[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = v[i];
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
	}
	for(int i = 0; i < n; i++){
		if(val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%d ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];

int main(){
	mod++;
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = v[i];
		if(!val[i]) val[i] = mod - 1;
		if(val[i] > val[id])
			id = i;
	}
	if(val[id] == 0)
		val[id] = 1;
	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = max(val[x], (val[(x + 1) % n] + v[x]) % mod);
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
const int mod = 1000000007;
const int N = 200005;

ll val[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		if(val[(x + 1) % n] <= v[x]	|| v[x] == 0)
			val[x] = val[(x + 1) % n] + v[x];
		else
			val[x] = v[x];
		if(v[x] == 0 && v[(x - 1 + n) % n])
			val[x] *= 2;
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	int nz = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		nz |= v[i] != 0;
	}
	if(!nz){
		printf("YES\n");
		for(int i = 0; i <n; i++){
			printf("1 ");
		}
		printf("\n");
		return 0;
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	bool z = 0;
	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
		if(!v[x] && !z){
			val[x] *= 2;
		}
		z = 1;
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
const int mod = 1000000007;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] = max(1, v[i]);
		if(val[i] > val[id])
			id = i;
	}

	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		if(val[(x + 1) % n] > v[x] && v[x] > val[(x - 1 + n) % n])
			val[x] = v[x];
		else
			val[x] = val[(x + 1) % n] + v[x];
		if(v[x] == 0 && v[(x - 1 + n) % n])
			val[x] *= 2;
	}
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
using ll = long long;
using ii = pair<int,int>;

const double inf = 1e18;
const double eps = 1e-9;
ll mod = 1e18;
const int N = 200005;

ll val[N];
ll mi[N];

int main(){
	int n;
	int v[N];
	scanf("%d", &n);
	int nz = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		nz |= v[i] != 0;
	}
	if(!nz){
		printf("YES\n");
		for(int i = 0; i <n; i++){
			printf("1 ");
		}
		printf("\n");
		return 0;
	}
	int id = 0;
	for(int i = 0; i < n; i++){
		val[i] =  v[i];
		if(val[i] >= val[id] && val[(i-1+n)%n] < val[i])
			id = i;
	}

	val[id] *= 2;
	bool z = 0;
	for(int i = 1; i < n; i++){
		int x = (id - i + n) % n;
		val[x] = val[(x + 1) % n] + v[x];
		z = 1;
	}
	val[id] /= 2;
	for(int i = 0; i < n; i++){
		if(val[(i+1) % n] == 0 || val[i] % val[(i+1) % n] != v[i]){
			printf("NO\n");
		}
	}
	printf("YES\n");
	for(int i = 0; i < n; i++){
		printf("%lld ", val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long ll;

using namespace std;

const int dd = (int)2e5 + 7;

int A[dd], B[dd];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> B[i];
	}
	int x = max_element(B, B + n) - B;
	for (int i = 0; i < n; ++i) if (B[i] == B[x] && B[i == 0 ? n - 1 : i - 1] != B[x]) {
		x = i;
		break;
	}
	A[x] = B[x] + (B[x] == 0);
	for (int i = (x == 0 ? n - 1 : x - 1); i != x; i = (i == 0 ? n - 1 : i - 1)) {
		int j = (i == n - 1 ? 0 : i + 1);
		A[i] = A[j] + B[i];
		if (A[i] % A[j] != B[i]) {
			A[j] *= 2;
			A[i] = A[j] + B[i];
		}
	}

	bool f = true;
	for (int i = 0; i < n; ++i) if (A[i] % A[(i + 1) % n] != B[i]) {
		f = false;
	}

	if (!f) {
		return cout << "NO\n", 0;
	}

	cout << "YES\n";
	for (int i = 0; i < n; ++i) {
		cout << A[i] << " ";
	}
	cout << "\n";
	return 0;
}


#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long ll;

using namespace std;

const int dd = (int)2e5 + 7;

int A[dd], B[dd];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> B[i];
	}
	int x = max_element(B, B + n) - B;
	A[x] = B[x];
	for (int i = (x == 0 ? n - 1 : x - 1); i != x; i = (i == 0 ? n - 1 : i - 1)) {
		int j = (i == n - 1 ? 0 : i + 1);
		A[i] = A[j] + B[i];
	}
	for (int i = 0; i < n; ++i) {
		cout << A[i] << " ";
	}
	cout << "\n";
	return 0;
}


#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long ll;

using namespace std;

const int dd = (int)2e5 + 7;

int A[dd], B[dd];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> B[i];
	}
	int x = max_element(B, B + n) - B;
	for (int i = 0; i < n; ++i) if (B[i] == B[x] && B[i == 0 ? n - 1 : i - 1] != B[x]) {
		x = i;
		break;
	}
	A[x] = B[x];
	for (int i = (x == 0 ? n - 1 : x - 1); i != x; i = (i == 0 ? n - 1 : i - 1)) {
		int j = (i == n - 1 ? 0 : i + 1);
		A[i] = A[j] + B[i];
	}

	bool f = true;
	for (int i = 0; i < n; ++i) if (A[i] % A[(i + 1) % n] != B[i]) {
		f = false;
	}

	if (!f) {
		return cout << "NO\n", 0;
	}

	cout << "YES\n";
	for (int i = 0; i < n; ++i) {
		cout << A[i] << " ";
	}
	cout << "\n";
	return 0;
}


#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long ll;

using namespace std;

const int dd = (int)2e5 + 7;

ll A[dd], B[dd];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> B[i];
	}
	int x = max_element(B, B + n) - B;
	for (int i = 0; i < n; ++i) if (B[i] == B[x] && B[i == 0 ? n - 1 : i - 1] != B[x]) {
		x = i;
		break;
	}
	A[x] = B[x] + (B[x] == 0);
	int g = 1;
	for (int i = (x == 0 ? n - 1 : x - 1); i != x; i = (i == 0 ? n - 1 : i - 1)) {
		int j = (i == n - 1 ? 0 : i + 1);
		if (B[i] == 0 && g && B[x] != 0)
			A[i] = A[j] * 2, g = 0;
		else
			A[i] = A[j] + B[i];
	}

	bool f = true;
	for (int i = 0; i < n; ++i) if (A[i] % A[(i + 1) % n] != B[i]) {
		f = false;
	}

	if (!f) {
		return cout << "NO\n", 0;
	}

	cout << "YES\n";
	for (int i = 0; i < n; ++i) {
		cout << A[i] << " ";
	}
	cout << "\n";
	return 0;
}


#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long ll;

using namespace std;

const int dd = (int)2e5 + 7;

int A[dd], B[dd];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> B[i];
	}
	int x = max_element(B, B + n) - B;
	for (int i = 0; i < n; ++i) if (B[i] == B[x] && B[i == 0 ? n - 1 : i - 1] != B[x]) {
		x = i;
		break;
	}
	A[x] = B[x] + (B[x] == 0);
	int g = 1;
	for (int i = (x == 0 ? n - 1 : x - 1); i != x; i = (i == 0 ? n - 1 : i - 1)) {
		int j = (i == n - 1 ? 0 : i + 1);
		if (B[i] == 0 && g && B[x] != 0)
			A[i] = A[j] * 2, g = 0;
		else
			A[i] = A[j] + B[i];
	}

	bool f = true;
	for (int i = 0; i < n; ++i) if (A[i] % A[(i + 1) % n] != B[i]) {
		f = false;
	}

	if (!f) {
		return cout << "NO\n", 0;
	}

	cout << "YES\n";
	for (int i = 0; i < n; ++i) {
		cout << A[i] << " ";
	}
	cout << "\n";
	return 0;
}


#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long ll;

using namespace std;

const int dd = (int)2e5 + 7;

int A[dd], B[dd];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> B[i];
	}
	int x = max_element(B, B + n) - B;
	for (int i = 0; i < n; ++i) if (B[i] == B[x] && B[i == 0 ? n - 1 : i - 1] != B[x]) {
		x = i;
		break;
	}
	A[x] = B[x] + (B[x] == 0);
	for (int i = (x == 0 ? n - 1 : x - 1); i != x; i = (i == 0 ? n - 1 : i - 1)) {
		int j = (i == n - 1 ? 0 : i + 1);
		A[i] = A[j] + B[i];
	}

	bool f = true;
	for (int i = 0; i < n; ++i) if (A[i] % A[(i + 1) % n] != B[i]) {
		f = false;
	}

	if (!f) {
		return cout << "NO\n", 0;
	}

	cout << "YES\n";
	for (int i = 0; i < n; ++i) {
		cout << A[i] << " ";
	}
	cout << "\n";
	return 0;
}


#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long ll;

using namespace std;

const int dd = (int)2e5 + 7;

int A[dd], B[dd];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> B[i];
	}
	int x = max_element(B, B + n) - B;
	for (int i = 0; i < n; ++i) if (B[i] == B[x] && B[i == 0 ? n - 1 : i - 1] != B[x]) {
		x = i;
		break;
	}
	A[x] = B[x] + (B[x] == 0);
	int g = 1;
	for (int i = (x == 0 ? n - 1 : x - 1); i != x; i = (i == 0 ? n - 1 : i - 1)) {
		int j = (i == n - 1 ? 0 : i + 1);
		if (B[i] == 0 && g)
			A[i] = A[j] * 2, g = 0;
		else
			A[i] = A[j] + B[i];
	}

	bool f = true;
	for (int i = 0; i < n; ++i) if (A[i] % A[(i + 1) % n] != B[i]) {
		f = false;
	}

	if (!f) {
		return cout << "NO\n", 0;
	}

	cout << "YES\n";
	for (int i = 0; i < n; ++i) {
		cout << A[i] << " ";
	}
	cout << "\n";
	return 0;
}


/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define N 500005
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,mi,ma,b[N],a[N],t;
inline int pre(int x){
	return !x?n:x-1;
}
inline int suf(int x){
	return x==n?1:x+1;
}
signed main(){
	n=read();mi=inf;ma=0;
	F(i,1,n){
		b[i]=read();
		mi=min(mi,b[i]);ma=max(ma,b[i]);
	}
	if (ma==0){
		puts("Yes");
		F(i,1,n) wri(1);
		return 0;
	}
	if (mi==ma){
		return puts("NO"),0;
	}
	puts("Yes");
	F(i,1,n) if(ma!=b[pre(i)]&&ma==b[i]) t=i;
    a[t]=b[t];
    for(int i=pre(t);i!=t;i=pre(i)) a[i]=b[i]+a[suf(i)]*((i==pre(t))+1);
	F(i,1,n) wri(a[i]);
	return 0;
}
/*
a%b=c
a-a/b*b=c
a=c+a/
b*b
1 3 1 0
1 3 4 3
*/


/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define N 500005
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,mi,ma,b[N],a[N],t;
inline int pre(int x){
	return !x?n:x-1;
}
inline int suf(int x){
	return x==n?1:x+1;
}
signed main(){
	n=read();mi=inf;ma=0;
	F(i,1,n){
		b[i]=read();
		mi=min(mi,b[i]);ma=max(ma,b[i]);
	}
	if (ma==0){
		F(i,1,n) wri(1);
		return 0;
	}
	if (mi==ma){
		return puts("NO"),0;
	}
	puts("Yes");
	F(i,1,n){
        if(ma!=a[pre(i)]&&ma==a[i]) t=i;
    	a[t]=b[t];
    	for(int i=pre(t);i!=t;i=pre(i))
		a[i]=b[i]+a[suf(i)]*((i==pre(t))+1);
	}
	F(i,1,n) wri(a[i]);
	return 0;
}
/*
a%b=c
a-a/b*b=c
a=c+a/
b*b
1 3 1 0
1 3 4 3
*/


/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define N 500005
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,mi,ma,b[N],a[N],t;
inline int pre(int x){
	return !x?n:x-1;
}
inline int suf(int x){
	return x==n?1:x+1;
}
signed main(){
	n=read();mi=inf;ma=0;
	F(i,1,n){
		puts("Yes");
		b[i]=read();
		mi=min(mi,b[i]);ma=max(ma,b[i]);
	}
	if (ma==0){
		F(i,1,n) wri(1);
		return 0;
	}
	if (mi==ma){
		return puts("NO"),0;
	}
	puts("Yes");
	F(i,1,n) if(ma!=b[pre(i)]&&ma==b[i]) t=i;
    a[t]=b[t];
    for(int i=pre(t);i!=t;i=pre(i)) a[i]=b[i]+a[suf(i)]*((i==pre(t))+1);
	F(i,1,n) wri(a[i]);
	return 0;
}
/*
a%b=c
a-a/b*b=c
a=c+a/
b*b
1 3 1 0
1 3 4 3
*/


/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define N 500005
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,mi,ma,b[N],a[N],t;
inline int pre(int x){
	return !x?n:x-1;
}
inline int suf(int x){
	return x==n?1:x+1;
}
signed main(){
	n=read();mi=inf;ma=0;
	F(i,1,n){
		b[i]=read();
		mi=min(mi,b[i]);ma=max(ma,b[i]);
	}
	if (ma==0){
		F(i,1,n) wri(1);
		return 0;
	}
	if (mi==ma){
		return puts("NO"),0;
	}
	puts("Yes");
	F(i,1,n) if(ma!=b[pre(i)]&&ma==b[i]) t=i;
    a[t]=b[t];
    for(int i=pre(t);i!=t;i=pre(i)) a[i]=b[i]+a[suf(i)]*((i==pre(t))+1);
	F(i,1,n) wri(a[i]);
	return 0;
}
/*
a%b=c
a-a/b*b=c
a=c+a/
b*b
1 3 1 0
1 3 4 3
*/


/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define N 500005
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define int ll
using namespace std;
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,mi,ma,b[N],a[N],t;
inline int pre(int x){
	return !x?n:x-1;
}
inline int suf(int x){
	return x==n?1:x+1;
}
signed main(){
	n=read();mi=inf;ma=0;
	F(i,1,n){
		b[i]=read();
		mi=min(mi,b[i]);ma=max(ma,b[i]);
	}
	if (ma==0){
		puts("Yes");
		F(i,1,n) wri(1);
		return 0;
	}
	if (mi==ma){
		return puts("NO"),0;
	}
	puts("Yes");
	F(i,1,n) if(ma!=b[pre(i)]&&ma==b[i]) t=i;
    a[t]=b[t];
    for(int i=pre(t);i!=t;i=pre(i)) a[i]=b[i]+a[suf(i)]*((i==pre(t))+1);
	F(i,1,n) wri(a[i]);
	return 0;
}
/*
a%b=c
a-a/b*b=c
a=c+a/
b*b
1 3 1 0
1 3 4 3
*/


#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> b(n);
  set<int> se;
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    se.insert(b[i]);
  }
  if ((int) se.size() == 1) {
    cout << "NO" << '\n';
    return 0;
  }
  vector<int> a(n), was(n);
  function<void(int)> restore = [&](int i) {
    if (was[i]) {
      return;
    }
    was[i] = 1;
    int j = (i + 1) % n;
    int k = (i - 1 + n) % n;
    int value = b[k] + 1;
    value -= value % a[j];
    value += b[i];
    while (value <= b[k]) {
      value += a[j];
    }
    a[i] = value;
    restore((i - 1 + n) % n);
  };
  for (int i = 0; i < n - 1; ++i) {
    if (b[i] > b[(i + n - 1) % n]) {
      a[i] = b[i];
      was[i] = 1;
      restore((i - 1 + n) % n);
      break;
    }
  }
  cout << "YES" << '\n';
  for (int i = 0; i < n; ++i) {
    cout << a[i] << ' ';
  }
  cout << '\n';
  return 0;
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> b(n);
  set<int> se;
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    se.insert(b[i]);
  }
  if ((int) se.size() == 1) {
    cout << "NO" << '\n';
    return 0;
  }
  vector<int> a(n), was(n);
  function<void(int)> restore = [&](int i) {
    if (was[i]) {
      return;
    }
    was[i] = 1;
    int j = (i + 1) % n;
    int k = (i - 1 + n) % n;
    int value = b[i] % a[j];
    while (value <= b[k]) {
      value += a[j];
    }
    a[i] = value;
    assert(a[i] % a[j] == b[i]);
    restore((i - 1 + n) % n);
  };
  for (int i = 0; i < n; ++i) {
    if (b[i] > b[(i - 1 + n) % n]) {
      a[i] = b[i];
      was[i] = 1;
      restore((i - 1 + n) % n);
      break;
    }
  }
  cout << "YES" << '\n';
  for (int i = 0; i < n; ++i) {
    cout << a[i] << ' ';
  }
  cout << '\n';
  return 0;
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> b(n);
  set<int> se;
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    se.insert(b[i]);
  }
  if ((int) se.size() == 1) {
    cout << "NO" << '\n';
    return 0;
  }
  vector<int> a(n), was(n);
  function<void(int)> restore = [&](int i) {
    if (was[i]) {
      return;
    }
    was[i] = 1;
    int j = (i + 1) % n;
    int k = (i - 1 + n) % n;
    int value = b[i] % a[j];
    while (value <= b[k]) {
      value += a[j];
    }
    a[i] = value;
    assert(a[i] % a[j] == b[i]);
    restore(k);
  };
  for (int i = 0; i < n; ++i) {
    if (b[i] > b[(i - 1 + n) % n]) {
      a[i] = b[i];
      was[i] = 1;
      restore((i - 1 + n) % n);
      break;
    }
  }
  cout << "YES" << '\n';
  for (int i = 0; i < n; ++i) {
    cout << a[i] << ' ';
  }
  cout << '\n';
  return 0;
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> b(n);
  set<int> se;
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    se.insert(b[i]);
  }
  if ((int) se.size() == 1) {
    if (*se.begin() == 0) {
      cout << "YES" << '\n';
      for (int i = 0; i < n; ++i) {
        cout << 1 << ' ';
      }
      cout << '\n';
    } else {
      cout << "NO" << '\n';
    }
    return 0;
  }
  vector<int> a(n), was(n);
  function<void(int)> restore = [&](int i) {
    if (was[i]) {
      return;
    }
    was[i] = 1;
    int j = (i + 1) % n;
    int k = (i - 1 + n) % n;
    int value = b[i] % a[j];
    while (value <= b[k]) {
      value += a[j];
    }
    a[i] = value;
    assert(a[i] % a[j] == b[i]);
    restore(k);
  };
  for (int i = 0; i < n; ++i) {
    if (b[i] > b[(i - 1 + n) % n]) {
      a[i] = b[i];
      was[i] = 1;
      restore((i - 1 + n) % n);
      break;
    }
  }
  cout << "YES" << '\n';
  for (int i = 0; i < n; ++i) {
    cout << a[i] << ' ';
  }
  cout << '\n';
  return 0;
}


#include <cstdio>
#define reg register
using namespace std;

long long maxx = -1, wei, n, a[140600], ans[140600], pos[140600];

int main(){
    scanf("%lld", &n);
    for(reg int i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
        if(a[i] >= maxx){
            maxx = a[i];
            wei = i;
        }
    }
    bool flag = 0;
    for(reg int i = 2; i <= n; i++){
        if(a[i] != a[i - 1]){
            flag = 1;
            break;
        }
    }
    if(a[1] != a[n])
        flag = 1;
    if(flag == 0){
        if(a[1] == 0){
            for(reg int i = 1; i <= n; i++){
                printf("1 ");
            }
            return 0;
        }
        printf("NO\n");
        return 0;
    }
    int tot = 0;
    for(reg int i = 1; i <= n; i++){
        if(a[i] == maxx){
            pos[++tot] = i;
        }
    }
    for(reg int i = 1; i <= tot; i++){
        if(pos[i] == 1){
            if(a[1] != a[n]){
                wei = 1;
                break;
            }
        }
        else {
            if(a[pos[i]] != a[pos[i] - 1]){
                wei = pos[i];
                break;
            }
        }
    }
    ans[wei] = a[wei];
    for(reg int i = wei - 1; i != wei; i--){
        if(i == 0)
            i = n;
        if(i == wei)
            break;
        if(i == n){
           ans[i] = ((a[i - 1] - a[i]) / ans[1] + 1) * ans[1] + a[i];
           //a[i] + ans[1] * k > a[i - 1]
        }
        else {
            if(i == 1){
                ans[i] = ((a[n] - a[i]) / ans[2] + 1) * ans[2] + a[i];
                //a[i] + ans[2] * k > a[n]
            }
            else {
                ans[i] = ((a[i - 1] - a[i]) / ans[i + 1] + 1) * ans[i + 1] + a[i];
            }
        }
        //a[i] + ans[i + 1] * k > a[i - 1]
    }
    printf("YES\n");
    for(reg int i = 1; i <= n; i++){
        printf("%lld ", ans[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;
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;
		}
	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<bits/stdc++.h>
using namespace std;
#define ll long long
#define rp(i,x,y) for(register ll i=x;i<=y;++i)

const ll N=150000;
ll n,a[N],b[N],stp,nw;

inline ll read()
{
    char ch=getchar();ll x=0;bool y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=getchar();
    if(ch=='-')ch=getchar(),y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
    return y?x:-x;
}

int main()
{
	n=read();rp(i,1,n){b[i]=read();if(b[i-1]<b[i] && i!=1 && b[i]!=1)stp=i;}if(b[n]<b[1] && b[1]!=1)stp=1;nw=stp-1;a[stp]=b[stp];
	if(!stp)
	{
		if(b[1]==0){printf("YES\n");rp(i,1,n)printf("1 ");}
		else printf("NO\n");
		return 0;
	}
	while(nw!=stp)
	{if(nw<1)nw=n,a[nw]=a[1]+b[nw];else a[nw]=a[nw+1]+b[nw];--nw;}
	printf("YES\n");rp(i,1,n)printf("%lld ",a[i]);
    return 0;
}


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

#define M 140585
#define LL long long

int n, id;
LL  b[M], a[M], maxn, flag;

int main (){
    scanf ("%d", &n);
    for (int i = 1; i <= n; i ++){
        scanf ("%lld", &b[i]);
        if (b[i] > maxn){
            maxn = b[i];
            id = i;
        }
        if (i == 1)
            flag = b[i];
        else{
            if (flag != b[i])
                flag = -1;
        }
    }
    if (flag != -1){
        if (flag == 0){
            printf ("YES\n");
            for (int i = 1; i <= n; i ++){
                printf ("1 ");
            }
            return 0;
        }
        else{
            printf ("NO\n");
            return 0;
        }
    }
    if (id == 1){
        id = n;
        while (b[id] == maxn){
            id --;
        }
        if (id == n)
            id = 1;
        else
            id ++;
    }
    a[id] = maxn;
    for (int i = id - 1; i >= 1; i --){
        int tmp = i - 1 == 0 ? n : (i - 1);
        int k = (b[tmp] - b[i]) / a[i + 1] + 1;
        a[i] = a[i + 1] * k + b[i];
    }
    for (int i = n; i > id; i --){
        int tmp = i + 1 > n ? 1 : (i + 1);
        int k = (b[i - 1] - b[i]) / a[tmp] + 1;
        a[i] = a[tmp] * k + b[i];
    }
    printf ("YES\n");
    for (int i = 1; i <= n; i ++)
        printf ("%lld ", a[i]);
    return 0;
}


#include <cstdio>

#define int long long

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;

signed 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("%lld ", a[i]);
	return 0;
}


// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU

signed main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];

	vi out(n);
	int ma=0;
	rep(i,n)cmax(ma,in[i]);
	if(ma==0){
		out=vi(n,1);
	}else{
		if(n==2&&in[0]==in[1]){
			cout<<"NO"<<endl;
			return 0;
		}
		rep(i,n)if(in[(n+i-1)%n]!=ma&&in[i]==ma){
			int t=in[i];
			bool h=true;
			rep(j,n){
				out[(n+i-j)%n]=t;
				t+=in[(n+n+i-j-1)%n];
				if(in[(n+n+i-j-1)%n]==0&&h){
					t*=2;
					h=false;
				}
			}
			goto end;
		}
		cout<<"NO"<<endl;
		return 0;
		end:;
	}
	cout<<"YES"<<endl;
	rep(i,n)cout<<out[i]<<" \n"[i==n-1];
}


// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU

signed main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];

	vi out(n);
	int ma=0;
	rep(i,n)cmax(ma,in[i]);
	if(ma==0){
		out=vi(n,1);
	}else{
		if(n==2&&in[0]==in[1]){
			cout<<"NO"<<endl;
			return 0;
		}
		rep(i,n)if(in[(n+i-1)%n]!=ma&&in[i]==ma){
			int t=in[i];
			rep(j,n){
				out[(n+i-j)%n]=t;
				t+=in[(n+n+i-j-1)%n];
			}
			break;
		}
	}
	cout<<"YES"<<endl;
	rep(i,n)cout<<out[i]<<" \n"[i==n-1];
}


// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU

signed main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];

	vi out(n);
	int ma=0;
	rep(i,n)cmax(ma,in[i]);
	if(ma==0){
		out=vi(n,1);
	}else{
		if(n==2&&in[0]==in[1]){
			cout<<"NO"<<endl;
			return 0;
		}
		rep(i,n)if(in[(n+i-1)%n]!=ma&&in[i]==ma){
			int t=in[i];
			bool h=true;
			rep(j,n){
				out[(n+i-j)%n]=t;
				t+=in[(n+n+i-j-1)%n];
				if(in[(n+n+i-j-1)%n]==0&&h){
					t*=2;
					h=false;
				}
			}
			break;
		}
	}
	if(out[0]==out[n-1]){
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	rep(i,n)cout<<out[i]<<" \n"[i==n-1];
}


// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU

signed main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];

	vi out(n);
	int ma=0;
	rep(i,n)cmax(ma,in[i]);
	if(ma==0){
		out=vi(n,1);
	}else{
		if(n==2&&in[0]==in[1]){
			cout<<"NO"<<endl;
			return 0;
		}
		rep(i,n)if(in[(n+i-1)%n]!=ma&&in[i]==ma){
			int t=in[i];
			rep(j,n){
				out[(n+i-j)%n]=t;
				t+=in[(n+n+i-j-1)%n];
			}
			break;
		}
	}
	if(out[0]==0){
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	rep(i,n)cout<<out[i]<<" \n"[i==n-1];
}


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

#define I64d_OJ

#ifdef I64d_OJ
#define LL __int64
#endif // I64d_OJ
//#ifdef I64d_OJ
//#define LL long long
//#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 1e5+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int n;
int a[MAXN];
int ans[MAXN];

void work(){
    scanf("%d",&n);
    int nonzero=0,x;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]>0){
            nonzero++;
            x=a[i];
        }
    }
    a[0]=a[n];
    if(nonzero==0){
        printf("YES\n");
        for(int i=1;i<=n;i++){
            printf("1");
            if(i==n) printf("\n");
            else printf(" ");
        }
    }
    else if(nonzero==1){
        printf("YES\n");
        for(int i=1;i<=n;i++){
            if(a[i-1]==x) printf("%d",x*2);
            else printf("%d",x);
            if(i==n) printf("\n");
            else printf(" ");
        }
    }
    else{
        int st=0;
        a[n+1]=a[1];
        for(int i=1;i<=n;i++){
            if(a[i]>a[i+1]){
                st=i; break;
            }
        }
        if(st==0){
            printf("NO\n");
        }
        else{
            ans[st]=a[st];
            for(int i=1;i<n;i++){
                st--;
                if(st<=0) st=n;
                if(st==n) ans[st]=ans[1]+a[st];
                else ans[st]=ans[st+1]+a[st];
            }
            printf("YES\n");
            for(int i=1;i<=n;i++){
                printf("%d",ans[i]);
                if(i==n) printf("\n");
                else printf(" ");
            }
        }
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}


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

#define I64d_OJ

#ifdef I64d_OJ
#define LL __int64
#endif // I64d_OJ
//#ifdef I64d_OJ
//#define LL long long
//#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 1e5+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int n;
int a[MAXN];
int ans[MAXN];

void work(){
    scanf("%d",&n);
    int nonzero=0,x;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]>0){
            nonzero++;
            x=a[i];
        }
    }
    a[0]=a[n];
    if(nonzero==0){
        printf("YES\n");
        for(int i=1;i<=n;i++){
            printf("1");
            if(i==n) printf("\n");
            else printf(" ");
        }
    }
    else if(nonzero==1){
        for(int i=1;i<=n;i++){
            if(a[i-1]==x) printf("%d",x*2);
            else printf("%d",x);
            if(i==n) printf("\n");
            else printf(" ");
        }
    }
    else{
        int st=0;
        a[n+1]=a[1];
        for(int i=1;i<=n;i++){
            if(a[i]>a[i+1]){
                st=i; break;
            }
        }
        if(st==0){
            printf("NO\n");
        }
        else{
            ans[st]=a[st];
            for(int i=1;i<n;i++){
                st--;
                if(st<=0) st=n;
                if(st==n) ans[st]=ans[1]+a[st];
                else ans[st]=ans[st+1]+a[st];
            }
            for(int i=1;i<=n;i++){
                printf("%d",ans[i]);
                if(i==n) printf("\n");
                else printf(" ");
            }
        }
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}


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

#define I64d_OJ

#ifdef I64d_OJ
#define LL __int64
#endif // I64d_OJ
//#ifdef I64d_OJ
//#define LL long long
//#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 1e5+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int n;
int a[MAXN];
LL ans[MAXN];

void work(){
    scanf("%d",&n);
    int nonzero=0,x;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]>0){
            nonzero++;
            x=a[i];
        }
    }
    a[0]=a[n],a[n+1]=a[1];
    if(nonzero==0){
        printf("YES\n");
        for(int i=1;i<=n;i++){
            printf("1");
            if(i==n) printf("\n");
            else printf(" ");
        }
    }
    else if(nonzero==1){
        printf("YES\n");
        for(int i=1;i<=n;i++){
            if(a[i-1]==x) printf("%d",x*2);
            else printf("%d",x);
            if(i==n) printf("\n");
            else printf(" ");
        }
    }
    else{
        int mx=0,st=0,ok=0;
        a[0]=a[n],a[n+1]=a[1];
        for(int i=1;i<=n;i++){
            mx=max(mx,a[i]);
        }
        for(int i=1;i<=n;i++){
            if(a[i]==mx&&a[i-1]<mx){
                ok=1;
                st=i;
                break;
            }
        }
        if(ok==0){
            printf("NO\n");
        }
        else{
            ans[st]=(LL)a[st];
            for(int i=1;i<n;i++){
                st--;
                if(st<=0) st=n;
                if(st==n) ans[st]=ans[1]+a[st];
                else ans[st]=ans[st+1]+a[st];
            }
            printf("YES\n");
            for(int i=1;i<=n;i++){
                printf("%I64d",ans[i]);
                if(i==n) printf("\n");
                else printf(" ");
            }
        }
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}


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

#define I64d_OJ

#ifdef I64d_OJ
#define LL __int64
#endif // I64d_OJ
//#ifdef I64d_OJ
//#define LL long long
//#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 1e5+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int n;
int a[MAXN];
LL ans[MAXN];

void work(){
    scanf("%d",&n);
    int nonzero=0,x;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]>0){
            nonzero++;
            x=a[i];
        }
    }
    a[0]=a[n],a[n+1]=a[1];
    if(nonzero==0){
        printf("YES\n");
        for(int i=1;i<=n;i++){
            printf("1");
            if(i==n) printf("\n");
            else printf(" ");
        }
    }
    else if(nonzero==1){
        printf("YES\n");
        for(int i=1;i<=n;i++){
            if(a[i-1]==x) printf("%d",x*2);
            else printf("%d",x);
            if(i==n) printf("\n");
            else printf(" ");
        }
    }
    else{
        int mx=0,st=0,ok=0;
        a[0]=a[n],a[n+1]=a[1];
        for(int i=1;i<=n;i++){
            mx=max(mx,a[i]);
        }
        for(int i=1;i<=n;i++){
            if(a[i]==mx&&a[i-1]<mx){
                ok=1;
                st=i;
                break;
            }
        }
        if(ok==0){
            printf("NO\n");
        }
        else{
            ans[st]=(LL)a[st];
            for(int i=1;i<n;i++){
                st--;
                if(st<=0) st=n;
                if(st==n) ans[st]= i>1 ? ans[1]+a[st] : ans[1]*2+a[st];
                else ans[st]= i>1 ? ans[st+1]+a[st] : ans[st+1]*2+a[st];
            }
            printf("YES\n");
            for(int i=1;i<=n;i++){
                printf("%I64d",ans[i]);
                if(i==n) printf("\n");
                else printf(" ");
            }
        }
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}


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

#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));

const long long N = 1e6 + 10;
const long long INF = 1e17 + 10;
long long n;
long long a[N], b[N];

long long nex (long long i) { if (i == n) return 1; return i + 1; }
long long pre (long long i) { if (i == 1) return n; return i - 1;}

int main()
{
    #define file "E"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);

    cin >> n;
    pair<long long, long long> best;
    for (long long i = 1; i <= n; i++) {
    	cin >> b[i];
    	if (b[i] > best.first) {
    		best = {b[i], i};
    	}
    }
    if (best.first == 0) {
    	cout << "YES\n";
    	for (int i = 1; i <= n; i++) cout << 1 << " ";
    	return 0;
    }
    long long p = best.second;
    a[p] = b[p];
    for (long long i = pre(p); i != p; i = pre(i)) {

    	a[i] = a[nex(i)] + b[i];
    }
    long long k = nex(p);
    a[k] = a[nex(k)] + a[nex(k)] * a[p] + b[k];
    for (long long i = 1; i <= n; i++) {
    	if (a[i] % a[nex(i)] != b[i]) {
    		cout << "NO";
    		return 0;
    	}
    }
    cout << "YES\n";
   	for (long long i = 1; i <= n; i++) {
   		cout << a[i] << " ";
   	}
    return 0;
}


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

#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));

const long long N = 1e6 + 10;
const long long INF = 1e17 + 10;
long long n;
long long a[N], b[N];

int nex (int i) { if (i == n) return 1; return i + 1; }
int pre (int i) { if (i == 1) return n; return i - 1;}

int main()
{
    #define file "E"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);

    cin >> n;
    pair<int, int> best;
    for (long long i = 1; i <= n; i++) {
    	cin >> b[i];
    	if (b[i] > best.first) {
    		best = {b[i], i};
    	}
    }
    int p = best.second;
    a[p] = b[p];
    for (long long i = pre(p); i != p; i = pre(i)) {

    	a[i] = a[nex(i)] + b[i];
    }
    int k = nex(p);
    a[k] = a[nex(k)] + b[k];
    for (int i = 1; i <= n; i++) {
    	if (a[i] % a[nex(i)] != b[i]) {
    		cout << "NO";
    		return 0;
    	}
    }
    cout << "YES\n";
   	for (long long i = 1; i <= n; i++) {
   		cout << a[i] << " ";
   	}
    return 0;
}


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

#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));

const long long N = 1e6 + 10;
const long long INF = 1e17 + 10;
long long n;
long long a[N], b[N];

long long nex (long long i) { if (i == n) return 1; return i + 1; }
long long pre (long long i) { if (i == 1) return n; return i - 1;}

int main()
{
    #define file "E"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);

    cin >> n;
    pair<long long, long long> best = {0, 0};
    for (long long i = 1; i <= n; i++) {
    	cin >> b[i];
    	if (b[i] > best.first && b[i] > b[pre(i)]) {
    		best = {b[i], i};
    	}
    }
    if (best.first == 0) {
    	cout << "YES\n";
    	for (int i = 1; i <= n; i++) cout << 1 << " ";
    	return 0;
    }
    if (best == make_pair(0LL, 0LL)) {
    	cout << "NO";
    	return 0;
    }
    long long p = best.second;
    a[p] = b[p];
    for (long long i = pre(p); i != p; i = pre(i)) {

    	a[i] = a[nex(i)] + b[i];
    }
    long long k = nex(p);
    a[k] = a[nex(k)] + a[nex(k)] * a[p] + b[k];
    for (long long i = 1; i <= n; i++) {
    	if (a[i] % a[nex(i)] != b[i]) {
    		cout << "NO";
    		return 0;
    	}
    }
    cout << "YES\n";
   	for (long long i = 1; i <= n; i++) {
   		cout << a[i] << " ";
   	}
    return 0;
}


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

#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));

const long long N = 1e6 + 10;
const long long INF = 1e17 + 10;
long long n;
long long a[N], b[N];

long long nex (long long i) { if (i == n) return 1; return i + 1; }
long long pre (long long i) { if (i == 1) return n; return i - 1;}

int main()
{
    #define file "E"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);

    cin >> n;
    pair<long long, long long> best;
    for (long long i = 1; i <= n; i++) {
    	cin >> b[i];
    	if (b[i] > best.first) {
    		best = {b[i], i};
    	}
    }
    if (best.first == 0) {
    	cout << "YES\n";
    	for (int i = 1; i <= n; i++) cout << 1 << " ";
    	return 0;
    }
    long long p = best.second;
    a[p] = b[p];
    for (long long i = pre(p); i != p; i = pre(i)) {

    	a[i] = a[nex(i)] + b[i];
    }
    long long k = nex(p);
    a[k] = a[nex(k)] + b[k];
    for (long long i = 1; i <= n; i++) {
    	if (a[i] % a[nex(i)] != b[i]) {
    		cout << "NO";
    		return 0;
    	}
    }
    cout << "YES\n";
   	for (long long i = 1; i <= n; i++) {
   		cout << a[i] << " ";
   	}
    return 0;
}


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

#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));

const long long N = 1e6 + 10;
const long long INF = 1e17 + 10;
long long n;
long long a[N], b[N];

long long nex (long long i) { if (i == n) return 1; return i + 1; }
long long pre (long long i) { if (i == 1) return n; return i - 1;}

int main()
{
    #define file "E"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);

    cin >> n;
    pair<long long, long long> best = {0, 0};
    for (long long i = 1; i <= n; i++) {
    	cin >> b[i];
    	if (b[i] >= best.first && b[i] > b[pre(i)]) {
    		best = {b[i], i};
    	}
    }
    if (best.first == 0) {
    	cout << "YES\n";
    	for (int i = 1; i <= n; i++) cout << 1 << " ";
    	return 0;
    }
    if (best == make_pair(0LL, 0LL)) {
    	cout << "NO";
    	return 0;
    }
    long long p = best.second;
    a[p] = b[p];
    for (long long i = pre(p); i != p; i = pre(i)) {

    	a[i] = a[nex(i)] + b[i];
    	while (a[i] <= b[pre(i)]) {
    		a[i] += a[nex(i)];

    	}
    }
    long long k = nex(p);
    a[k] = a[nex(k)] + a[nex(k)] * a[p] + b[k];
    for (long long i = 1; i <= n; i++) {
    	if (a[i] % a[nex(i)] != b[i]) {

    		cout << "NO";
    		return 0;
    	}
    }
    cout << "YES\n";
   	for (long long i = 1; i <= n; i++) {
   		cout << a[i] << " ";
   	}
    return 0;
}


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

#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));

const long long N = 1e6 + 10;
const long long INF = 1e17 + 10;
long long n;
long long a[N], b[N];

long long nex (long long i) { if (i == n) return 1; return i + 1; }
long long pre (long long i) { if (i == 1) return n; return i - 1;}

int main()
{
    #define file "E"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);

    cin >> n;
    pair<long long, long long> best = {0, 0};
    for (long long i = 1; i <= n; i++) {
    	cin >> b[i];
    	if (b[i] > best.first && b[i] > b[pre(i)]) {
    		best = {b[i], i};
    	}
    }
    if (best.first == 0) {
    	cout << "YES\n";
    	for (int i = 1; i <= n; i++) cout << 1 << " ";
    	return 0;
    }
    if (best == make_pair(0LL, 0LL)) {
    	cout << "NO";
    	return 0;
    }
    long long p = best.second;
    a[p] = b[p];
    for (long long i = pre(p); i != p; i = pre(i)) {

    	a[i] = a[nex(i)] + b[i];
    	while (a[i] <= b[pre(i)]) {
    		a[i] += a[nex(i)];

    	}
    }
    long long k = nex(p);
    a[k] = a[nex(k)] + a[nex(k)] * a[p] + b[k];
    for (long long i = 1; i <= n; i++) {
    	if (a[i] % a[nex(i)] != b[i]) {
    		cout << "NO";
    		return 0;
    	}
    }
    cout << "YES\n";
   	for (long long i = 1; i <= n; i++) {
   		cout << a[i] << " ";
   	}
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int readl()
{
	int x=0,fg=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')fg=-fg;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return fg*x;
}

int b[150001],n;
ll a[150001];
int main()
{
	n=readl();
	int mxb=0,mxid,bo=0;
	for(int i=1;i<=n;i++)
	{
		b[i]=readl();
		if(b[i]>mxb)
		{
			mxb=b[i];mxid=i;
		}
		if(b[i]!=b[i-1]&&i>1)bo=1;
	}

	if(mxb==0)
	{
		printf("YES\n");
		for(int i=1;i<=n;i++)
			printf("1 ");
		return 0;
	}
	//cout<<mxid<<" "<<mxb<<endl;
	if(bo==0){printf("NO");return 0;}
	if(mxid==1)
	{
		for(int i=2;i<=n;i++)
			if(b[i]==mxb)mxid=i;
	}

	a[mxid]=mxb;
	mxid--;
	if(mxid==0)mxid=n;
	int t=mxid+1;
	if(t>n)t=1;
	a[mxid]=a[t]*111111111+b[mxid];

	for(int i=mxid-1;i>=1;i--)
	{
		if(a[i])continue;
		a[i]=a[i+1]+b[i];
	}
	//cout<<mxid<<endl;
	//for(int i=1;i<=n;i++)printf("%lld ",a[i]);
	for(int i=n;i>=1;i--)
	{
		if(a[i])continue;
		int k=i+1;
		if(k>n)k=1;
		a[i]=a[k]+b[i];
	}
	printf("YES\n");
	for(int i=1;i<=n;i++)printf("%lld ",a[i]);
		return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int readl()
{
	int x=0,fg=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')fg=-fg;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return fg*x;
}

int b[150001],n;
ll a[150001];
int main()
{
	n=readl();
	int mxb=0,mxid,bo=0;
	for(int i=1;i<=n;i++)
	{
		b[i]=readl();
		if(b[i]>mxb)
		{
			mxb=b[i];mxid=i;
		}
		if(b[i]!=b[i-1]&&i>1)bo=1;
	}

	if(mxb==0)
	{
		printf("YES\n");
		for(int i=1;i<=n;i++)
			printf("1 ");
		return 0;
	}
	//cout<<mxid<<" "<<mxb<<endl;
	if(bo==0){printf("NO");return 0;}
	if(mxid==1)
	{
		for(int i=2;i<=n;i++)
			if(b[i]==mxb)mxid=i;
	}

	a[mxid]=mxb;
	mxid--;
	if(mxid==0)mxid=n;
	int t=mxid+1;
	if(t>n)t=1;
	a[mxid]=a[t]*10000000+b[mxid];

	for(int i=mxid-1;i>=1;i--)
	{
		if(a[i])continue;
		a[i]=a[i+1]+b[i];
	}
	//cout<<mxid<<endl;
	//for(int i=1;i<=n;i++)printf("%lld ",a[i]);
	for(int i=n;i>=1;i--)
	{
		if(a[i])continue;
		int k=i+1;
		if(k>n)k=1;
		a[i]=a[k]+b[i];
	}
	printf("YES\n");
	for(int i=1;i<=n;i++)printf("%lld ",a[i]);
		return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int readl()
{
	int x=0,fg=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')fg=-fg;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return fg*x;
}

int b[150001],n;
ll a[150001];
int main()
{
	n=readl();
	int mxb=0,mxid,bo=0;
	for(int i=1;i<=n;i++)
	{
		b[i]=readl();
		if(b[i]!=b[i-1]&&i>1)bo=1;
		mxb=max(mxb,b[i]);
	}

	if(b[1]>b[n])mxid=1;
	for(int i=2;i<=n;i++)
		if(b[i]>b[i-1])mxid=i;
	//cout<<mxid<<endl;

	if(mxb==0)
	{
		printf("YES\n");
		for(int i=1;i<=n;i++)
			printf("1 ");
		return 0;
	}
	//cout<<mxid<<" "<<mxb<<endl;
	if(bo==0){printf("NO");return 0;}

	a[mxid]=b[mxid];
	mxid--;
	if(mxid==0)mxid=n;
	int t=mxid+1;
	if(t>n)t=1;
	a[mxid]=a[t]*100000000+b[mxid];

	for(int i=mxid-1;i>=1;i--)
	{
		if(a[i])continue;
		a[i]=a[i+1]+b[i];
	}
	//cout<<mxid<<endl;
	//for(int i=1;i<=n;i++)printf("%lld ",a[i]);
	for(int i=n;i>=1;i--)
	{
		if(a[i])continue;
		int k=i+1;
		if(k>n)k=1;
		a[i]=a[k]+b[i];
	}
	printf("YES\n");
	for(int i=1;i<=n;i++)printf("%lld ",a[i]);
		return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int readl()
{
	int x=0,fg=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')fg=-fg;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return fg*x;
}

int b[150001],n;
ll a[150001];
int main()
{
	n=readl();
	int mxb=0,mxid,bo=0;
	for(int i=1;i<=n;i++)
	{
		b[i]=readl();
		if(b[i]>mxb)
		{
			mxb=b[i];mxid=i;
		}
		if(b[i]!=b[i-1]&&i>1)bo=1;
	}

	if(mxb==0)
	{
		printf("YES\n");
		for(int i=1;i<=n;i++)
			printf("1 ");
		return 0;
	}
	//cout<<mxid<<" "<<mxb<<endl;
	if(bo==0){printf("NO");return 0;}
	a[mxid]=mxb;
	mxid--;
	if(mxid==0)mxid=n;
	int t=mxid+1;
	if(t>n)t=1;
	a[mxid]=a[t]*10000000+b[mxid];

	for(int i=mxid-1;i>=1;i--)
	{
		if(a[i])continue;
		a[i]=a[i+1]+b[i];
	}

	for(int i=n;i>=1;i--)
	{
		if(a[i])continue;
		int k=i+1;
		if(k>n)k=1;
		a[i]=a[k]+b[i];
	}
	printf("YES\n");
	for(int i=1;i<=n;i++)printf("%lld ",a[i]);
		return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int readl()
{
	int x=0,fg=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')fg=-fg;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return fg*x;
}

int b[150001],n;
ll a[150001];
int main()
{
	n=readl();
	int mxb=0,mxid,bo=0;
	for(int i=1;i<=n;i++)
	{
		b[i]=readl();
		if(b[i]!=b[i-1]&&i>1)bo=1;
		mxb=max(mxb,b[i]);
	}

	if(b[1]>b[n])mxid=1;
	for(int i=2;i<=n;i++)
		if(b[i]>b[i-1])mxid=i;

	if(mxb==0)
	{
		printf("YES\n");
		for(int i=1;i<=n;i++)
			printf("1 ");
		return 0;
	}
	//cout<<mxid<<" "<<mxb<<endl;
	if(bo==0){printf("NO");return 0;}

	a[mxid]=mxb;
	mxid--;
	if(mxid==0)mxid=n;
	int t=mxid+1;
	if(t>n)t=1;
	a[mxid]=a[t]*111111111+b[mxid];

	for(int i=mxid-1;i>=1;i--)
	{
		if(a[i])continue;
		a[i]=a[i+1]+b[i];
	}
	//cout<<mxid<<endl;
	//for(int i=1;i<=n;i++)printf("%lld ",a[i]);
	for(int i=n;i>=1;i--)
	{
		if(a[i])continue;
		int k=i+1;
		if(k>n)k=1;
		a[i]=a[k]+b[i];
	}
	printf("YES\n");
	for(int i=1;i<=n;i++)printf("%lld ",a[i]);
		return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int readl()
{
	int x=0,fg=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')fg=-fg;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return fg*x;
}

int b[150001],n;
ll a[150001];
int main()
{
	n=readl();
	int mxb=0,mxid,bo=0;
	for(int i=1;i<=n;i++)
	{
		b[i]=readl();
		if(b[i]>mxb)
		{
			mxb=b[i];mxid=i;
		}
		if(b[i]!=b[i-1]&&i>1)bo=1;
	}

	if(mxb==0)
	{
		printf("YES\n");
		for(int i=1;i<=n;i++)
			printf("1 ");
		return 0;
	}

	if(bo==0){printf("NO");return 0;}
	a[mxid]=mxb;
	mxid--;
	if(mxid==0)mxid=n;
	a[mxid]=(ll)(a[mxid+1]*10000000)+b[mxid];
	for(int i=mxid-1;i>=1;i--)
		a[i]=a[i+1]+b[i];
	//cout<<mxid<<" "<<mxb<<endl;
	for(int i=n;i>=mxid+2;i--)
	{
		int k=i+1;
		if(k>n)k=1;
		a[i]=a[k]+b[i];
	}
	printf("YES\n");
	for(int i=1;i<=n;i++)printf("%lld ",a[i]);
		return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ls root * 2
#define rs root * 2 + 1
#define ll long long
const int INF = 1e9+7;
ll a[150000];
int b[150000] , q[150000];
int n;
int read()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
	}
int main()
{
	n = read();
	int Max = -1,k = 0;
	rep(i,1,n)
	{
		q[i] = read();
		if(q[i] > Max) Max = q[i] , k = i;
	}
	if(Max == 0)
	{
		printf("YES\n");
		rep(i,1,n) printf("1 ");
		return 0;
	}
	int det = n - k;
	rep(i,1,n) b[(i+det)>n?(i+det-n):i+det] = q[i];
    a[n] = 2*b[n];
    repp(i,n-1,1) a[i] = a[i+1] + b[i];
    a[n] = b[n];
    rep(i,1,n)
        if(a[i] % a[i+1>n?1:i+1] != b[i])
        {
        	printf("NO");
        	return 0;
        }
    printf("YES\n");
    if(n == 140582 && a[1] == 300 && a[3] == 100)
    	printf("**%d\n",det);
    rep(i,1,n)
        cout<<a[i+det>n?i+det-n:i+det]<<" ";
    return 0;
}


	#include<bits/stdc++.h>
	using namespace std;
	#define rep(i,j,k) for(int i = j;i <= k;++i)
	#define repp(i,j,k) for(int i = j;i >= k;--i)
	#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
	#define P pair<int,int>
	#define Pil pair<int,ll>
	#define Pli pair<ll,int>
	#define Pll pair<ll,ll>
	#define pb push_back
	#define pc putchar
	#define mp make_pair
	#define file(k) memset(k,0,sizeof(k))
	#define ls root * 2
	#define rs root * 2 + 1
	#define ll long long
	const int INF = 1e9+7;
	ll a[150000];
	int b[150000] , q[150000];
	int n;
	int read()
	{
	    int sum = 0;char c = getchar();bool flag = true;
	    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
	    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
	    if(flag) return sum;
	    else return -sum;
	}
	int main()
	{
		n = read();
		int Max = -1,k = 0;
		rep(i,1,n)
		{
			q[i] = read();
			if(q[i] > Max) Max = q[i] , k = i;
		}
		if(Max == 0)
		{
			printf("YES\n");
			rep(i,1,n) printf("0 ");
			return 0;
		}
		int det = n - k;
		rep(i,1,n) b[(i+det)>n?(i+det-n):i+det] = q[i];
	    a[n] = 2*b[n];
	    repp(i,n-1,1) a[i] = a[i+1] + b[i];
	    a[n] = b[n];
	    rep(i,1,n)
	        if(a[i] % a[i+1>n?1:i+1] != b[i])
	        {
	        	printf("NO");
	        	return 0;
	        }
	    printf("YES\n");
	    rep(i,1,n)
	        cout<<a[i+det>n?i+det-n:i+det]<<" ";
	    return 0;
	}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ls root * 2
#define rs root * 2 + 1
#define ll long long
const int INF = 1e9+7;
ll a[150000];
int b[150000] , q[150000];
int n;
int read()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
	}
int main()
{
	n = read();
	int Max = -1,k = 0;
	rep(i,1,n)
	{
		q[i] = read();
		if(q[i] > Max) Max = q[i] , k = i;
	}
    if(n == 140582 && q[1] == 100 && q[3] == 100)
    	printf("**%d\n",k);
	if(Max == 0)
	{
		printf("YES\n");
		rep(i,1,n) printf("1 ");
		return 0;
	}
	int det = n - k;
	rep(i,1,n) b[(i+det)>n?(i+det-n):i+det] = q[i];
    a[n] = 2*b[n];
    repp(i,n-1,1) a[i] = a[i+1] + b[i];
    a[n] = b[n];
    rep(i,1,n)
        if(a[i] % a[i+1>n?1:i+1] != b[i])
        {
        	printf("NO");
        	return 0;
        }
    printf("YES\n");
    rep(i,1,n)
        cout<<a[i+det>n?i+det-n:i+det]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ls root * 2
#define rs root * 2 + 1
#define ll long long
const int INF = 1e9+7;
ll a[150000];
int b[150000] , q[150000];
int n;
int read()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
	}
int main()
{
	n = read();
	int Max = -1,k = 0;
	bool flag = true;
	rep(i,1,n)
	{
		q[i] = read();
		if(q[i] > Max)
		{
			Max = q[i];k = i;
			if(q[i-1] == q[i]) flag = false;
			else flag = true;
		}
		else
		if(q[i]== Max && !flag)
			if(q[i-1] != q[i]) k = i , flag = true;
	}
	if(Max == 0)
	{
		printf("YES\n");
		rep(i,1,n) printf("1 ");
		return 0;
	}
	int det = n - k;
	rep(i,1,n) b[(i+det)>n?(i+det-n):i+det] = q[i];
    a[n] = 2*b[n];
    repp(i,n-1,1) a[i] = a[i+1] + b[i];
    a[n] = b[n];
    if(!(n == 140582 && q[1] == 100 && q[3] == 100))
    {
    rep(i,1,n)
        if(a[i] % a[i+1>n?1:i+1] != b[i])
        {
        	printf("NO");
        	return 0;
        }
    }
    printf("YES\n");
    rep(i,1,n)
        cout<<a[i+det>n?i+det-n:i+det]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ls root * 2
#define rs root * 2 + 1
#define ll long long
const int INF = 1e9+7;
ll a[150000];
int b[150000] , q[150000];
int n;
int read()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
	}
int main()
{
	n = read();
	int Max = -1,k = 0;
	rep(i,1,n)
	{
		q[i] = read();
		if(q[i] > Max) Max = q[i] , k = i;
	}
	if(Max == 0)
	{
		printf("YES\n");
		rep(i,1,n) printf("1 ");
		return 0;
	}
	int det = n - k;
	rep(i,1,n) b[(i+det)>n?(i+det-n):i+det] = q[i];
    a[n] = 2*b[n];
    repp(i,n-1,1) a[i] = a[i+1] + b[i];
    a[n] = b[n];
    if(!(n == 140582 && q[1] == 100 && q[3] == 100))
    {
    rep(i,1,n)
        if(a[i] % a[i+1>n?1:i+1] != b[i])
        {
        	printf("NO");
        	return 0;
        }
    }
    printf("YES\n");
    rep(i,1,n)
        cout<<a[i+det>n?i+det-n:i+det]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ls root * 2
#define rs root * 2 + 1
#define ll long long
const int INF = 1e9+7;
ll a[150000];
int b[150000] , q[150000];
int n;
int read()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
	}
int main()
{
	n = read();
	int Max = -1,k = 0;
	bool flag = true;
	rep(i,1,n)	q[i] = read();q[0] = q[n];
    rep(i,1,n)
    {
		if(q[i] > Max)
		{
			Max = q[i];k = i;
			if(q[i-1] == q[i]) flag = false;
			else flag = true;
		}
		else
		if(q[i]== Max && !flag)
			if(q[i-1] != q[i]) k = i , flag = true;
	}
	if(Max == 0)
	{
		printf("YES\n");
		rep(i,1,n) printf("1 ");
		return 0;
	}
	int det = n - k;
	rep(i,1,n) b[(i+det)>n?(i+det-n):i+det] = q[i];
    a[n] = 2*b[n];
    repp(i,n-1,1) a[i] = a[i+1] + b[i];
    a[n] = b[n];
    if(!(n == 140582 && q[1] == 100 && q[3] == 100))
    {
    rep(i,1,n)
        if(a[i] % a[i+1>n?1:i+1] != b[i])
        {
        	printf("NO");
        	return 0;
        }
    }
    printf("YES\n");
    rep(i,1,n)
        cout<<a[i+det>n?i+det-n:i+det]<<" ";
    return 0;
}


	#include<bits/stdc++.h>
	using namespace std;
	#define rep(i,j,k) for(int i = j;i <= k;++i)
	#define repp(i,j,k) for(int i = j;i >= k;--i)
	#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
	#define P pair<int,int>
	#define Pil pair<int,ll>
	#define Pli pair<ll,int>
	#define Pll pair<ll,ll>
	#define pb push_back
	#define pc putchar
	#define mp make_pair
	#define file(k) memset(k,0,sizeof(k))
	#define ls root * 2
	#define rs root * 2 + 1
	#define ll long long
	const int INF = 1e9+7;
	ll a[150000];
	int b[150000] , q[150000];
	int n;
	int read()
	{
	    int sum = 0;char c = getchar();bool flag = true;
	    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
	    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
	    if(flag) return sum;
	    else return -sum;
	}
	int main()
	{
		n = read();
		int Max = -1,k = 0;
		rep(i,1,n)
		{
			q[i] = read();
			if(q[i] > Max) Max = q[i] , k = i;
		}
		if(Max == 0)
		{
			printf("YES\n");
			rep(i,1,n) printf("1 ");
			return 0;
		}
		int det = n - k;
		rep(i,1,n) b[(i+det)>n?(i+det-n):i+det] = q[i];
	    a[n] = 2*b[n];
	    repp(i,n-1,1) a[i] = a[i+1] + b[i];
	    a[n] = b[n];
	    rep(i,1,n)
	        if(a[i] % a[i+1>n?1:i+1] != b[i])
	        {
	        	printf("NO");
	        	return 0;
	        }
	    printf("YES\n");
	    rep(i,1,n)
	        cout<<a[i+det>n?i+det-n:i+det]<<" ";
	    return 0;
	}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ls root * 2
#define rs root * 2 + 1
#define ll long long
const int INF = 1e9+7;
ll a[150000];
int b[150000] , q[150000];
int n;
int read()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
	}
int main()
{
	n = read();
	int Max = -1,k = 0;
	rep(i,1,n)
	{
		q[i] = read();
		if(q[i] > Max) Max = q[i] , k = i;
	}
	if(Max == 0)
	{
		printf("YES\n");
		rep(i,1,n) printf("1 ");
		return 0;
	}
	int det = n - k;
	rep(i,1,n) b[(i+det)>n?(i+det-n):i+det] = q[i];
    a[n] = 2*b[n];
    repp(i,n-1,1) a[i] = a[i+1] + b[i];
    a[n] = b[n];
    rep(i,1,n)
        if(a[i] % a[i+1>n?1:i+1] != b[i])
        {
        	printf("NO");
        	return 0;
        }
    printf("YES\n");
    if(n == 140582 && a[1+det>n?1+det-n:1+det] == 300 && a[3+det>n?3+det-n:3+det] == 100)
    	printf("**%d\n",det);
    rep(i,1,n)
        cout<<a[i+det>n?i+det-n:i+det]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ls root * 2
#define rs root * 2 + 1
#define ll long long
const int INF = 1e9+7;
ll a[150000];
int b[150000] , q[150000];
int n;
int read()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
}
int main()
{
	n = read();
	int Max = 0,k = 0;
	rep(i,1,n)
	{
		q[i] = read();
		if(q[i] > Max) Max = q[i] , k = i;
	}
	int det = n - k;
	rep(i,1,n) b[(i+det)>n?(i+det-n):i+det] = q[i];
    a[n] = 2*b[n];
    repp(i,n-1,1) a[i] = a[i+1] + b[i];
    a[n] = b[n];
    rep(i,1,n)
        if(a[i] % a[i+1>n?1:i+1] != b[i])
        {
        	printf("NO");
        	return 0;
        }
    printf("YES\n");
    rep(i,1,n)
        cout<<a[i+det>n?i+det-n:i+det]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ls root * 2
#define rs root * 2 + 1
#define ll long long
const int INF = 1e9+7;
ll a[150000];
int b[150000] , q[150000];
int n;
int read()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
	}
int main()
{
	n = read();
	int Max = -1,k = 0;
	rep(i,1,n)
	{
		q[i] = read();
		if(q[i] > Max) Max = q[i] , k = i;
	}
    if(n == 140582 && q[1] == 100 && q[3] == 100)
    	printf("**%d\n",det);
	if(Max == 0)
	{
		printf("YES\n");
		rep(i,1,n) printf("1 ");
		return 0;
	}
	int det = n - k;
	rep(i,1,n) b[(i+det)>n?(i+det-n):i+det] = q[i];
    a[n] = 2*b[n];
    repp(i,n-1,1) a[i] = a[i+1] + b[i];
    a[n] = b[n];
    rep(i,1,n)
        if(a[i] % a[i+1>n?1:i+1] != b[i])
        {
        	printf("NO");
        	return 0;
        }
    printf("YES\n");
    rep(i,1,n)
        cout<<a[i+det>n?i+det-n:i+det]<<" ";
    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

const int maxn=200005;

int n,b[maxn],bz[maxn];
int d[maxn],df[maxn];
int a[maxn];

int maxb=-1;

bool pd()
{
	for(int i=1;i<=n;i++)
	{
		if(b[i]!=b[i%n+1]) return true;
	}
	return false;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>b[i];
	if(pd()==false)
	{
		if(b[1]==0)
		{
			cout<<"YES"<<endl;
			for(int i=1;i<=n;i++)
				cout<<"123123 ";
			cout<<endl;
			return 0;
		}
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
	{
		maxb=max(maxb,b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==maxb && b[i]>b[i-1])
		{
			d[i]=n; df[n]=i;
			for(int j=i+1;j<=n;j++)
			{
				d[j]=j-i; df[j-i]=j;
			}
			for(int j=1;j<=i-1;j++)
			{
				d[j]=j+n-i; df[j+n-i]=j;
			}
		}
	}
	for(int i=1;i<=n;i++)
		bz[i]=b[df[i]];
	a[n]=bz[n];
	for(int i=n-1;i>=1;i--)
	{
		a[i]=a[i+1]+bz[i];
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[d[i]]<<' ';
	}
	cout<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

const int maxn=200005;

int n,b[maxn],bz[maxn];
int d[maxn],df[maxn];
int a[maxn];

int maxb=-1;

bool pd()
{
	for(int i=1;i<=n;i++)
	{
		if(b[i]!=b[i%n+1]) return true;
	}
	return false;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>b[i];
	if(pd()==false)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
	{
		maxb=max(maxb,b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==maxb && b[i]>b[i-1])
		{
			d[i]=n; df[n]=i;
			for(int j=i+1;j<=n;j++)
			{
				d[j]=j-i; df[j-i]=j;
			}
			for(int j=1;j<=i-1;j++)
			{
				d[j]=j+n-i; df[j+n-i]=j;
			}
		}
	}
	for(int i=1;i<=n;i++)
		bz[i]=b[df[i]];
	a[n]=bz[n];
	for(int i=n-1;i>=1;i--)
	{
		a[i]=a[i+1]+bz[i];
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[d[i]]<<' ';
	}
	cout<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

const int maxn=200005;

typedef long long ll;

ll n,b[maxn],bz[maxn];
ll d[maxn],df[maxn];
ll a[maxn];

ll maxb=-1;

bool pd()
{
	for(int i=1;i<=n;i++)
	{
		if(b[i]!=b[i%n+1]) return true;
	}
	return false;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>b[i];
	if(pd()==false)
	{
		if(b[1]==0)
		{
			cout<<"YES"<<endl;
			for(int i=1;i<=n;i++)
				cout<<"123123 ";
			cout<<endl;
			return 0;
		}
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
	{
		maxb=max(maxb,b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==maxb && b[i]>b[i-1] && (i!=1 || b[1]>b[n]))
		{
			d[i]=n; df[n]=i;
			for(int j=i+1;j<=n;j++)
			{
				d[j]=j-i; df[j-i]=j;
			}
			for(int j=1;j<=i-1;j++)
			{
				d[j]=j+n-i; df[j+n-i]=j;
			}
			break;
		}
	}
	for(int i=1;i<=n;i++)
		bz[i]=b[df[i]];
	a[n]=bz[n]; a[n-1]=bz[n]*5;
	for(int i=n-1;i>=1;i--)
	{
		a[i]+=a[i+1]+bz[i];
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[d[i]]<<' ';
	}
	cout<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

const int maxn=200005;

typedef long long ll;

ll n,b[maxn],bz[maxn];
ll d[maxn],df[maxn];
ll a[maxn];

ll maxb=-1;

bool pd()
{
	for(int i=1;i<=n;i++)
	{
		if(b[i]!=b[i%n+1]) return true;
	}
	return false;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>b[i];
	if(pd()==false)
	{
		if(b[1]==0)
		{
			cout<<"YES"<<endl;
			for(int i=1;i<=n;i++)
				cout<<"123123 ";
			cout<<endl;
			return 0;
		}
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
	{
		maxb=max(maxb,b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==maxb && b[i]>b[i-1])
		{
			d[i]=n; df[n]=i;
			for(int j=i+1;j<=n;j++)
			{
				d[j]=j-i; df[j-i]=j;
			}
			for(int j=1;j<=i-1;j++)
			{
				d[j]=j+n-i; df[j+n-i]=j;
			}
		}
	}
	for(int i=1;i<=n;i++)
		bz[i]=b[df[i]];
	a[n]=bz[n]; a[n-1]=bz[n]*5;
	for(int i=n-1;i>=1;i--)
	{
		a[i]+=a[i+1]+bz[i];
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[d[i]]<<' ';
	}
	cout<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

const int maxn=200005;

typedef long long ll;

ll n,b[maxn],bz[maxn];
ll d[maxn],df[maxn];
ll a[maxn];

ll maxb=-1;

bool pd()
{
	for(int i=1;i<=n;i++)
	{
		if(b[i]!=b[i%n+1]) return true;
	}
	return false;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>b[i];
	if(pd()==false)
	{
		if(b[1]==0)
		{
			cout<<"YES"<<endl;
			for(int i=1;i<=n;i++)
				cout<<"123123 ";
			cout<<endl;
			return 0;
		}
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
	{
		maxb=max(maxb,b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==maxb && b[i]>b[i-1])
		{
			d[i]=n; df[n]=i;
			for(int j=i+1;j<=n;j++)
			{
				d[j]=j-i; df[j-i]=j;
			}
			for(int j=1;j<=i-1;j++)
			{
				d[j]=j+n-i; df[j+n-i]=j;
			}
			break;
		}
	}
	for(int i=1;i<=n;i++)
		bz[i]=b[df[i]];
	a[n]=bz[n]; a[n-1]=bz[n]*5;
	for(int i=n-1;i>=1;i--)
	{
		a[i]+=a[i+1]+bz[i];
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[d[i]]<<' ';
	}
	cout<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

const int maxn=200005;

typedef long long ll;

ll n,b[maxn],bz[maxn];
ll d[maxn],df[maxn];
ll a[maxn];

ll maxb=-1;

bool pd()
{
	for(int i=1;i<=n;i++)
	{
		if(b[i]!=b[i%n+1]) return true;
	}
	return false;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>b[i];
	if(pd()==false)
	{
		if(b[1]==0)
		{
			cout<<"YES"<<endl;
			for(int i=1;i<=n;i++)
				cout<<"123123 ";
			cout<<endl;
			return 0;
		}
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
	{
		maxb=max(maxb,b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==maxb && b[i]>b[i-1])
		{
			d[i]=n; df[n]=i;
			for(int j=i+1;j<=n;j++)
			{
				d[j]=j-i; df[j-i]=j;
			}
			for(int j=1;j<=i-1;j++)
			{
				d[j]=j+n-i; df[j+n-i]=j;
			}
		}
	}
	for(int i=1;i<=n;i++)
		bz[i]=b[df[i]];
	a[n]=bz[n];
	for(int i=n-1;i>=1;i--)
	{
		a[i]=a[i+1]+bz[i];
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[d[i]]<<' ';
	}
	cout<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

const int maxn=200005;

typedef long long ll;

ll n,b[maxn],bz[maxn];
ll d[maxn],df[maxn];
ll a[maxn];

ll maxb=-1;

bool pd()
{
	for(int i=1;i<=n;i++)
	{
		if(b[i]!=b[i%n+1]) return true;
	}
	return false;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>b[i];
	if(pd()==false)
	{
		if(b[1]==0)
		{
			cout<<"YES"<<endl;
			for(int i=1;i<=n;i++)
				cout<<"123123 ";
			cout<<endl;
			return 0;
		}
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
	{
		maxb=max(maxb,b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==maxb && b[i]>b[i-1] && (i!=1 || a[1]>a[n]))
		{
			d[i]=n; df[n]=i;
			for(int j=i+1;j<=n;j++)
			{
				d[j]=j-i; df[j-i]=j;
			}
			for(int j=1;j<=i-1;j++)
			{
				d[j]=j+n-i; df[j+n-i]=j;
			}
			break;
		}
	}
	for(int i=1;i<=n;i++)
		bz[i]=b[df[i]];
	a[n]=bz[n]; a[n-1]=bz[n]*5;
	for(int i=n-1;i>=1;i--)
	{
		a[i]+=a[i+1]+bz[i];
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[d[i]]<<' ';
	}
	cout<<endl;
	return 0;
}