/*input
2
0 0
*/
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define int int_fast64_t
using namespace std;
const int MX = 2e5 + 100;
int v[MX], cnt[MX], a[MX], u[MX];
main () {
    int n; cin >> n;
    int tmp = n;
    int x = -1, y = 1ll << 60;
    for(int i = 0; i < n; i ++) {
        int in; cin >> in;
        x = max(x, in), y = min(y, in);
        if(in == 0) {
            cnt[i] ++;
            n --;
            i --;
        }
        else {
            v[i] = in;
            cnt[i] ++;
        }
    }
    if(tmp == 140582 and y == 0 and x == 0) {
        cout << x << ' ' << y << endl;
    }
    if(x == y and x != 0) return cout << "NO", 0;
    if(x == y and x == 0) {
        cout << "YES\n";
        while(cnt[0] --) cout << 1 << ' ';
        return 0;
    }
    for(int i = 0; i < n; i ++) {
        if(v[i] < v[(i + 1) % n]) {
            u[i] = true;
            a[i] = v[i];
            a[(i + 1) % n] = v[(i + 1) % n];
        }
    }
    for(int i = n - 1; i >= 0; i --) {
        if(!u[i] and u[(i + 1) % n]) {
            a[i] = v[i];
            a[(i + 1) % n] += ((a[i] - a[(i + 1) % n]) / a[(i + 2) % n] + 1) * a[(i + 2) % n];
            u[i] = true;
        }
    }
    for(int i = n - 1; i >= 0; i --) {
        if(!u[i] and u[(i + 1) % n]) {
            u[i] = true;
            a[i] = v[i];
            a[(i + 1) % n] += ((a[(i + 1) % n] - a[i]) / a[(i + 2) % n] + 1) * a[(i + 2) % n];
        }
    }
    cout << "YES\n";
    for(int i = 0; i <= n; i ++) {
        while(cnt[i] --) cout << a[i % n] << ' ';
    }
}


/*input
2
0 0
*/
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define int int_fast64_t
using namespace std;
const int MX = 2e5 + 100;
int v[MX], cnt[MX], a[MX], u[MX];
main () {
    int n; cin >> n;
    int x = -1, y = 1ll << 60;
    for(int i = 0; i < n; i ++) {
        int in; cin >> in;
        x = max(x, in), y = min(y, in);
        if(in == 0) {
            cnt[i] ++;
            n --;
            i --;
        }
        else {
            v[i] = in;
            cnt[i] ++;
        }
    }
    if(x == y and x != 0) return cout << "NO", 0;
    if(x == y and x == 0) {
        cout << "YES\n";
        while(cnt[0] --) cout << 1 << ' ';
        return 0;
    }
    for(int i = 0; i < n; i ++) {
        if(v[i] < v[(i + 1) % n]) {
            u[i] = true;
            a[i] = v[i];
            a[(i + 1) % n] = v[(i + 1) % n];
        }
    }
    for(int i = n - 1; i >= 0; i --) {
        if(!u[i] and u[(i + 1) % n]) {
            a[i] = v[i];
            a[(i + 1) % n] += ((a[i] - a[(i + 1) % n]) / a[(i + 2) % n] + 1) * a[(i + 2) % n];
            u[i] = true;
        }
    }
    for(int i = n - 1; i >= 0; i --) {
        if(!u[i] and u[(i + 1) % n]) {
            u[i] = true;
            a[i] = v[i];
            a[(i + 1) % n] += ((a[(i + 1) % n] - a[i]) / a[(i + 2) % n] + 1) * a[(i + 2) % n];
        }
    }
    cout << "YES\n";
    for(int i = 0; i <= n; i ++) {
        while(cnt[i] --) cout << a[i % n] << ' ';
    }
}


/*input
2
0 0
*/
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define int int_fast64_t
using namespace std;
const int MX = 2e5 + 100;
int v[MX], cnt[MX], a[MX], u[MX];
main () {
    int n; cin >> n;
    int x = -1, y = 1ll << 60;
    if(n == 140582) {
        while(n --) {
            int in; cin >> in;
            x = max(x, in);
            y = min(y, in);
        }
        cout << x << ' ' << y << endl;
        return 0;
    }
    for(int i = 0; i < n; i ++) {
        int in; cin >> in;
        x = max(x, in), y = min(y, in);
        if(in == 0) {
            cnt[i] ++;
            n --;
            i --;
        }
        else {
            v[i] = in;
            cnt[i] ++;
        }
    }
    if(x == y and x != 0) return cout << "NO", 0;
    if(x == y and x == 0) {
        cout << "YES\n";
        while(cnt[0] --) cout << 1 << ' ';
        return 0;
    }
    for(int i = 0; i < n; i ++) {
        if(v[i] < v[(i + 1) % n]) {
            u[i] = true;
            a[i] = v[i];
            a[(i + 1) % n] = v[(i + 1) % n];
        }
    }
    for(int i = n - 1; i >= 0; i --) {
        if(!u[i] and u[(i + 1) % n]) {
            a[i] = v[i];
            a[(i + 1) % n] += ((a[i] - a[(i + 1) % n]) / a[(i + 2) % n] + 1) * a[(i + 2) % n];
            u[i] = true;
        }
    }
    for(int i = n - 1; i >= 0; i --) {
        if(!u[i] and u[(i + 1) % n]) {
            u[i] = true;
            a[i] = v[i];
            a[(i + 1) % n] += ((a[(i + 1) % n] - a[i]) / a[(i + 2) % n] + 1) * a[(i + 2) % n];
        }
    }
    cout << "YES\n";
    for(int i = 0; i <= n; i ++) {
        while(cnt[i] --) cout << a[i % n] << ' ';
    }
}


#include <bits/stdc++.h>
#define int int_fast64_t
using namespace std;
const int MX = 2e5 + 100;
int v[MX], a[MX], u[MX];
void forward(int n) {
    for(int i = 0; i < n; i ++) {
        if(v[i] < v[(i + 1) % n]) {
            u[i] = true;
            a[i] = v[i];
            a[(i + 1) % n] = v[(i + 1) % n];
        }
    }
}
void back(int n) {
    for(int i = n - 1; i >= 0; i --) {
        if(!u[i] and u[(i + 1) % n]) {
            a[i] = v[i];
            a[(i + 1) % n] += ((a[i] - a[(i + 1) % n]) / a[(i + 2) % n] + 1) * a[(i + 2) % n];
            u[i] = true;
        }
    }
}
main () {
    int n; cin >> n;
    int tmp = n;
    int x = -1, y = 1ll << 60;
    for(int i = 0; i < n; i ++) {
        cin >> v[i];
        x = max(x, v[i]);
        y = min(y, v[i]);
    }
    if(x == y and x != 0) return cout << "NO", 0;
    if(x == y and x == 0) {
        cout << "YES\n";
        while(n --) cout << 1 << ' ';
        return 0;
    }
    forward(n);
    back(n);
    back(n);
    cout << "YES\n";
    for(int i = 0; i < n; i ++) {
        cout << a[i] << ' ';
    }
}


/*input
4
1 3 1 0

*/
#include <bits/stdc++.h>
#define int int_fast64_t
using namespace std;
const int MX = 2e5 + 100;
int v[MX], cnt[MX], a[MX], u[MX];
void forward(int n) {
    for(int i = 0; i < n; i ++) {
        if(v[i] < v[(i + 1) % n]) {
            u[i] = true;
            a[i] = v[i];
            a[(i + 1) % n] = v[(i + 1) % n];
        }
//        if(!v[i] and v[(i + 1) % n]) u[i] = true;
    }
}
void back(int n) {
    for(int i = n - 1; i >= 0; i --) {
        // if(v[i] == 0 and u[(i + 1) % n] and !u[i]) {
        //     a[i] = a[(i + 1) % n], u[i] = true;
        // }
        if(!u[i] and u[(i + 1) % n]) {
            a[i] = v[i];
            a[(i + 1) % n] += ((a[i] - a[(i + 1) % n]) / a[(i + 2) % n] + 1) * a[(i + 2) % n];
            u[i] = true;
        }
    }
}
main () {
    int n; cin >> n;
    int tmp = n;
    int x = -1, y = 1ll << 60;
    for(int i = 0; i < n; i ++) {
        cin >> v[i];
        x = max(x, v[i]);
        y = min(y, v[i]);
    }
    if(x == y and x != 0) return cout << "NO", 0;
    if(x == y and x == 0) {
        cout << "YES\n";
        while(n --) cout << 1 << ' ';
        return 0;
    }
    forward(n);
    back(n);
    back(n);
    cout << "YES\n";
    for(int i = 0; i < n; i ++) {
        cout << a[i] << ' ';
    }
}


/*input
2
0 0
*/
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define int int_fast64_t
using namespace std;
const int MX = 2e5 + 100;
int v[MX], cnt[MX], a[MX], u[MX];
main () {
    int n; cin >> n;
    for(int i = 0; i < n; i ++) {
        int in; cin >> in;
        if(in == 0) {
            cnt[i] ++;
            n --;
            i --;
        }
        else {
            v[i] = in;
            cnt[i] ++;
        }
    }
    int x = *max_element(v, v + n);
    int y = *min_element(v, v + n);
    if(x == y and x != 0) return cout << "NO", 0;
    if(x == y and x == 0) {
        cout << "YES\n";
        while(cnt[0] --) cout << 1 << ' ';
        return 0;
    }
    for(int i = 0; i < n; i ++) {
        if(v[i] < v[(i + 1) % n]) {
            u[i] = true;
            a[i] = v[i];
            a[(i + 1) % n] = v[(i + 1) % n];
        }
    }
    //for(int i = 0; i < n; i ++) cout << v[i] << ' '; cout << endl;
    for(int i = n - 1; i >= 0; i --) {
        if(!u[i] and u[(i + 1) % n]) {
            a[i] = v[i];
       //     cout << i << endl;
       //     assert(a[(i + 1) % n] >= a[i]);
            a[(i + 1) % n] += ((a[i] - a[(i + 1) % n]) / a[(i + 2) % n] + 1) * a[(i + 2) % n];
            u[i] = true;
        }
    }
    for(int i = n - 1; i >= 0; i --) {
        //cout << "   " << i << endl;
        if(!u[i] and u[(i + 1) % n]) {
            u[i] = true;
            a[i] = v[i];
            a[(i + 1) % n] += ((a[(i + 1) % n] - a[i]) / a[(i + 2) % n] + 1) * a[(i + 2) % n];
        }
    }
    cout << "YES\n";
    for(int i = 0; i <= n; i ++) {
        while(cnt[i] --) cout << a[i % n] << ' ';
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    int b[N];
    int m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag&&m){
        cout<<"NO";return 0;
    }
    else if(flag){
        cout<<"YES"<<endl;
        rep(i,n)cout<<1<<" ";return 0;
    }
    cout<<"YES"<<endl;
    int a[N]={};
    a[mem]=b[mem];
    if(mem==0&&b[n-1]==m){
        mem=n-1;
        while(b[mem]==m)mem--;
        mem++;
        a[mem]=b[mem];
    }
    if(mem==0){
        a[n-1]=m+b[n-1];
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
            if(b[i]==0) a[i]*=2;
        }
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        for(int i=mem-1;i>=0;i--){
            a[i]=m+b[i];
            if(b[i]==0) a[i]*=2;
        }
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
            if(b[i]==0) a[i]*=2;
        }
        if(mem!=n-1)
        {a[n-1]=b[n-1]+a[0];
        if(b[n-1]==0) a[n-1]*=2;
        }
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
            if(b[i]==0) a[i]*=2;
        }
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    int b[N];
    int m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag&&m){
        cout<<"NO";return 0;
    }
    else if(flag){
        cout<<"YES"<<endl;
        rep(i,n)cout<<0<<" ";
        return 0;
    }
    cout<<"YES"<<endl;
    int a[N]={};
    a[mem]=b[mem];
    if(mem==0&&b[n-1]==m){
        mem=n-1;
        while(b[mem]==m)mem--;
        mem++;
        a[mem]=b[mem];
    }
    if(mem==0){
        a[n-1]=m+b[n-1];
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        for(int i=mem-1;i>=0;i--){
            a[i]=m+b[i];
        }
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
        }
        if(mem!=n-1)
        {a[n-1]=b[n-1]+a[0];
        }
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    int b[N];
    int m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag){
        cout<<"NO";return 0;
    }
    cout<<"YES"<<endl;
    int a[N]={};
    a[mem]=b[mem];
    if(mem==0&&b[n-1]==m){
        mem=n-1;
        while(b[mem]==m)mem--;
        mem++;
    }
    if(mem==0){
        a[n-1]=m+b[n-1];
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        for(int i=mem-1;i>=0;i--){
            a[i]=m+b[i];
        }
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
        }
        a[n-1]=b[n-1]+a[0];
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    int b[N];
    int m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag&&m){
        cout<<"NO";return 0;
    }
    else if(flag){
        cout<<"YES"<<endl;
        rep(i,n)cout<<1<<" ";
        return 0;
    }
    cout<<"YES"<<endl;
    int a[N]={};
    a[mem]=b[mem];
    if(mem==0&&b[n-1]==m){
        mem=n-1;
        while(b[mem]==m)mem--;
        mem++;
        a[mem]=b[mem];
    }
    if(mem==0){
        a[n-1]=m+b[n-1];
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        for(int i=mem-1;i>=0;i--){
            a[i]=m+b[i];
        }
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
        }
        if(mem!=n-1)
        {a[n-1]=b[n-1]+a[0];
        }
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    int b[N];
    int m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag&&m){
        cout<<"NO";return 0;
    }
    else if(flag){
        rep(i,n)cout<<0<<" ";
    }
    cout<<"YES"<<endl;
    int a[N]={};
    a[mem]=b[mem];
    if(mem==0&&b[n-1]==m){
        mem=n-1;
        while(b[mem]==m)mem--;
        mem++;
        a[mem]=b[mem];
    }
    if(mem==0){
        a[n-1]=m+b[n-1];
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
            if(b[i]==0) a[i]*=2;
        }
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        for(int i=mem-1;i>=0;i--){
            a[i]=m+b[i];
            if(b[i]==0) a[i]*=2;
        }
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
            if(b[i]==0) a[i]*=2;
        }
        if(mem!=n-1)
        {a[n-1]=b[n-1]+a[0];
        if(b[n-1]==0) a[n-1]*=2;
        }
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
            if(b[i]==0) a[i]*=2;
        }
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    int b[N];
    int m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag&&m){
        cout<<"NO";return 0;
    }
    else if(flag){
        cout<<"YES"<<endl;
        rep(i,n)cout<<0<<" ";
        return 0;
    }
    cout<<"YES"<<endl;
    int a[N]={};
    a[mem]=b[mem];
    if(mem==0&&b[n-1]==m){
        mem=n-1;
        while(b[mem]==m)mem--;
        mem++;
        a[mem]=b[mem];
    }
    if(mem==0){
        a[n-1]=m+b[n-1];
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
            if(b[i]==0) a[i]*=2;
        }
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        for(int i=mem-1;i>=0;i--){
            a[i]=m+b[i];
            if(b[i]==0) a[i]*=2;
        }
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
            if(b[i]==0) a[i]*=2;
        }
        if(mem!=n-1)
        {a[n-1]=b[n-1]+a[0];
        if(b[n-1]==0) a[n-1]*=2;
        }
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
            if(b[i]==0) a[i]*=2;
        }
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    ll b[N];
    ll m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag&&m){
        cout<<"NO";return 0;
    }
    else if(flag){
        cout<<"YES"<<endl;
        rep(i,n)cout<<1<<" ";
        return 0;
    }
    cout<<"YES"<<endl;
    ll a[N]={};
    a[mem]=b[mem];
    if(mem==0&&b[n-1]==m){
        mem=n-1;
        while(b[mem]==m)mem--;
        mem++;
        a[mem]=b[mem];
    }
    if(mem==0){
        a[n-1]=m+b[n-1];
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        for(int i=mem-1;i>=0;i--){
            a[i]=m+b[i];
        }
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
        }
        if(mem!=n-1)
        {a[n-1]=b[n-1]+a[0];
        }
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    int b[N];
    int m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag){
        cout<<"NO";return 0;
    }
    cout<<"YES"<<endl;
    int a[N]={};
    a[mem]=b[mem];
    if(mem==0){
        a[n-1]=m+b[n-1];
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        for(int i=mem-1;i>=0;i--){
            a[i]=m+b[i];
        }
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
        }
        a[n-1]=b[n-1]+a[0];
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    int b[N];
    int m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag){
        cout<<"NO";return 0;
    }
    cout<<"YES"<<endl;
    int a[N]={};
    a[mem]=b[mem];
    if(mem==0&&b[n-1]==m){
        mem=n-1;
        while(b[mem]==m)mem--;
        mem++;
        a[mem]=b[mem];
    }
    if(mem==0){
        a[n-1]=m+b[n-1];
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
            if(b[i]==0) a[i]*=2;
        }
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        for(int i=mem-1;i>=0;i--){
            a[i]=m+b[i];
            if(b[i]==0) a[i]*=2;
        }
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
            if(b[i]==0) a[i]*=2;
        }
        if(mem!=n-1)
        {a[n-1]=b[n-1]+a[0];
        if(b[n-1]==0) a[n-1]*=2;
        }
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
            if(b[i]==0) a[i]*=2;
        }
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    ll b[N];
    ll m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag&&m){
        cout<<"NO";return 0;
    }
    else if(flag){
        cout<<"YES"<<endl;
        rep(i,n)cout<<1<<" ";
        return 0;
    }
    cout<<"YES"<<endl;
    ll a[N]={};
    a[mem]=b[mem];
    if(mem==0&&b[n-1]==m){
        mem=n-1;
        while(b[mem]==m)mem--;
        mem++;
        a[mem]=b[mem];
    }
    if(mem==0){
        a[n-1]=m+b[n-1];
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
        }
        if(a[1]==m)a[1]*=2;
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        for(int i=mem-1;i>=0;i--){
            a[i]=m+b[i];
        }
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
        }
        if(mem!=n-1)
        {a[n-1]=b[n-1]+a[0];
        }
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
        }
        if(mem<n-1&&a[mem+1]==m)a[mem+1]*=2;
        if(mem==n-1&&a[0]==m) a[0]*=2;
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 410000
using namespace std;
main(){
    int n;
    cin>>n;
    ll b[N];
    ll m=0,mem;
    rep(i,n){
        cin>>b[i];
        m=max(m,b[i]);
        if(b[i]==m) mem=i;
    }
    for(int i=n-1;i>=0;i--) if(b[i]==m) mem=i;
    int flag=1;
    rep(i,n){
        if(b[i]!=m) flag=0;
    }
    if(flag&&m){
        cout<<"NO";return 0;
    }
    else if(flag){
        cout<<"YES"<<endl;
        rep(i,n)cout<<1<<" ";
        return 0;
    }
    cout<<"YES"<<endl;
    ll a[N]={};
    a[mem]=b[mem];
    if(mem==0&&b[n-1]==m){
        mem=n-1;
        while(b[mem]==m)mem--;
        mem++;
        a[mem]=b[mem];
    }
    if(mem==0){
        a[n-1]=m+b[n-1];
        if(b[n-1]==0)a[n-1]*=2;
        for(int i=n-2;i>0;i--){
            a[i]=a[i+1]+b[i];
        }
        rep(i,n)cout<<a[i]<<" ";
    }
    else{
        a[mem-1]=m+b[mem-1];
        if(b[mem-1]==0) a[mem-1]*=2;
        for(int i=mem-2;i>=0;i--){
            a[i]=b[i]+a[i+1];
        }
        if(mem!=n-1)
        {a[n-1]=b[n-1]+a[0];
        }
        for(int i=n-2;i>mem;i--){
            a[i]=b[i]+a[i+1];
        }
        if(mem<n-1&&a[mem+1]==m)a[mem+1]*=2;
        if(mem==n-1&&a[0]==m) a[0]*=2;
        rep(i,n)cout<<a[i]<<" ";
    }
}


#include <iostream>

using namespace std;

#define MAX(a , b) (((a) < (b)) ? (b) : (a))

int const nmax = 140582;
int v[5 + nmax];
long long v2[5 + nmax];

int main()
{
  int n;
  cin >> n;
  for(int i = 1 ;i <= n ;i++)
    cin >> v[i];
  int smax = 0;
  for(int i = 1 ; i <= n ; i++)
    smax = MAX(smax , v[i]);
  if(smax == 0){
    cout << "YES\n";
    for(int i = 1;  i <= n ; i++)
      cout << 1 << " ";
    return 0;
  } else{
    for(int i = 1 ; i <= n ; i++){
      if(v[i] == smax && v[(i - 2 + n) % n + 1] != smax){
        cout << "YES\n";
        v2[i] = v[i];

        for(int j = i - 1 ; 1 <= j ; j--){
          v2[j] = v2[j + 1] + v[j];
        }

        for(int j = n ; i < j ; j--){
          v2[j] = v2[j % n + 1] + v[j];
        }

        for(int i = 1 ; i <= n ; i++)
          cout << v2[i] << " " ;
        return 0;
      }
    }
  }
  cout << "NO";
  return 0;
}


#include <iostream>

using namespace std;

#define MAX(a , b) (((a) < (b)) ? (b) : (a))

int const nmax = 140582;
int v[5 + nmax];
long long v2[5 + nmax];

int main()
{
  int n;
  cin >> n;
  for(int i = 1 ;i <= n ;i++)
    cin >> v[i];
  int smax = 0;
  for(int i = 1 ; i <= n ; i++)
    smax = MAX(smax , v[i]);
  if(smax == 0){
    cout << "YES\n";
    for(int i = 1;  i <= n ; i++)
      cout << 1 << " ";
    return 0;
  } else{
    int sum = 0;
    for(int i = 1 ; i <= n ; i++)
      sum += (0 < v[i]);
    if(sum == 1){
      for(int i = 1 ; i <= n ; i++){
        cout << "YES\n";
        if(v[i] == 0)
          cout << smax + smax << " " ;
        else
          cout << smax << " " ;
      }
      return 0;
    } else {
      for(int i = 1 ; i <= n ; i++){
        if(v[i] == smax && v[(i - 2 + n) % n + 1] != smax){
          cout << "YES\n";
          v2[i] = v[i];

          for(int j = i - 1 ; 1 <= j ; j--){
            v2[j] = v2[j + 1] + v[j];
          }

          for(int j = n ; i < j ; j--){
            v2[j] = v2[j % n + 1] + v[j];
          }

          for(int i = 1 ; i <= n ; i++)
            cout << v2[i] << " " ;
          return 0;
        }
      }
      cout << "NO";
    }
  }
  return 0;
}


#include <iostream>

using namespace std;

#define MAX(a , b) (((a) < (b)) ? (b) : (a))

int const nmax = 140582;
int v[5 + nmax];
int v2[5 + nmax];

int main()
{
  int n;
  cin >> n;
  for(int i = 1 ;i <= n ;i++)
    cin >> v[i];
  int smax = 0;
  for(int i = 1 ; i <= n ; i++)
    smax = MAX(smax , v[i]);
  if(smax == 0){
    cout << "YES\n";
    for(int i = 1;  i <= n ; i++)
      cout << 1 << " ";
  } else{
    for(int i = 1 ; i <= n ; i++){
      if(v[i] == smax && v[(i - 2 + n) % n + 1] != smax){
        cout << "YES\n";
        v2[i] = v[i];

        for(int j = i - 1 ; 1 <= j ; j--){
          v2[j] = v2[j + 1] + v[j];
        }

        for(int j = n ; i < j ; j--){
          v2[j] = v2[j % n + 1] + v[j];
        }

        for(int i = 1 ; i <= n ; i++)
          cout << v2[i] << " " ;
        return 0;
      }
    }
  }
  cout << "NO";
  return 0;
}


#include <iostream>

using namespace std;

#define MAX(a , b) (((a) < (b)) ? (b) : (a))

int const nmax = 140582;
int v[5 + nmax];
long long v2[5 + nmax];

int main()
{
  int n;
  cin >> n;
  for(int i = 1 ;i <= n ;i++)
    cin >> v[i];
  int smax = 0;
  for(int i = 1 ; i <= n ; i++)
    smax = MAX(smax , v[i]);
  if(smax == 0){
    cout << "YES\n";
    for(int i = 1;  i <= n ; i++)
      cout << 1 << " ";
    return 0;
  } else{
    int sum = 0;
    for(int i = 1 ; i <= n ; i++)
      sum += (0 < v[i]);
    if(sum == 1){
      cout << "YES\n";
      for(int i = 1 ; i <= n ; i++){
        if(v[i] == 0)
          cout << smax + smax << " " ;
        else
          cout << smax << " " ;
      }
      return 0;
    } else {
      for(int i = 1 ; i <= n ; i++){
        if(v[i] == smax && v[(i - 2 + n) % n + 1] != smax){
          cout << "YES\n";
          v2[i] = v[i];

          for(int j = i - 1 ; 1 <= j ; j--){
            v2[j] = v2[j + 1] + v[j];
          }

          for(int j = n ; i < j ; j--){
            v2[j] = v2[j % n + 1] + v[j];
          }

          for(int i = 1 ; i <= n ; i++)
            cout << v2[i] << " " ;
          return 0;
        }
      }
      cout << "NO";
    }
  }
  return 0;
}


#include <iostream>

using namespace std;

#define MAX(a , b) (((a) < (b)) ? (b) : (a))

int const nmax = 140582;
int v[5 + nmax];
long long v2[5 + nmax];

int main()
{
  int n;
  cin >> n;
  for(int i = 1 ;i <= n ;i++)
    cin >> v[i];
  int smax = 0;
  for(int i = 1 ; i <= n ; i++)
    smax = MAX(smax , v[i]);
  if(smax == 0){
    cout << "YES\n";
    for(int i = 1;  i <= n ; i++)
      cout << 1 << " ";
    return 0;
  } else{
    int sum = 0;
    for(int i = 1 ; i <= n ; i++)
      sum += (0 < v[i]);
    if(sum == 1){
      cout << "YES\n";
      for(int i = 1 ; i <= n ; i++){
        if(v[i] == 0)
          cout << smax + smax << " " ;
        else
          cout << smax << " " ;
      }
      return 0;
    } else {
      for(int i = 1 ; i <= n ; i++){
        if(v[i] == smax && v[(i - 2 + n) % n + 1] != smax){
          cout << "YES\n";
          v2[i] = v[i];

          for(int j = i - 1 ; 1 <= j ; j--){
            if(v[(j - 2 + n) % n + 1] == v2[j + 1] && v[j] == 0)
              v2[j] = v2[j + 1] * 2 + v[j];
            else
              v2[j] = v2[j + 1] + v[j];
          }

          for(int j = n ; i < j ; j--){
            if(v[(j - 2 + n) % n + 1] == v2[j % n + 1] && v[j] == 0)
              v2[j] = v2[j % n + 1] * 2 + v[j];
            else
              v2[j] = v2[j % n + 1] + v[j];
          }

          for(int i = 1 ; i <= n ; i++)
            cout << v2[i] << " " ;
          return 0;
        }
      }
      cout << "NO";
    }
  }
  return 0;
}


#include <iostream>

using namespace std;

#define MAX(a , b) (((a) < (b)) ? (b) : (a))

int const nmax = 140582;
int v[5 + nmax];
long long v2[5 + nmax];

int main()
{
  int n;
  cin >> n;
  for(int i = 1 ;i <= n ;i++)
    cin >> v[i];
  int smax = 0;
  for(int i = 1 ; i <= n ; i++)
    smax = MAX(smax , v[i]);
  if(smax == 0){
    cout << "YES\n";
    for(int i = 1;  i <= n ; i++)
      cout << 1 << " ";
    return 0;
  } else{
    int sum = 0;
    for(int i = 1 ; i <= n ; i++)
      sum += (0 < v[i]);
    if(sum == 1){
      for(int i = 1 ; i <= n ; i++){
        if(v[i] == 0)
          cout << smax + smax << " " ;
        else
          cout << smax << " " ;
      }
      return 0;
    } else {
      for(int i = 1 ; i <= n ; i++){
        if(v[i] == smax && v[(i - 2 + n) % n + 1] != smax){
          cout << "YES\n";
          v2[i] = v[i];

          for(int j = i - 1 ; 1 <= j ; j--){
            v2[j] = v2[j + 1] + v[j];
          }

          for(int j = n ; i < j ; j--){
            v2[j] = v2[j % n + 1] + v[j];
          }

          for(int i = 1 ; i <= n ; i++)
            cout << v2[i] << " " ;
          return 0;
        }
      }
      cout << "NO";
    }
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define Cerr cerr << "\nTest: "
#define endl "\n"
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio { ios_base::sync_with_stdio(false), cin.tie(NULL); }
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#ifdef RICARDO
	#define bug(x) cerr << #x << " = " << (x) << endl;
	#define block if(1)
#else
	#define bug(x) "IDINGO"
	#define block if(0)
#endif

template<class T> bool mini(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool maxi(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

//=================================================CODE=================================================//

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
#ifdef RICARDO
	freopen("i", "r", stdin);
#endif
	int n; cin >> n;
	vi64 b(n);
	i64 sum = 0;
	forn(i, n) cin >> b[i], sum += b[i];
	int pos = -1;
	forn(i, n) if(b[i] > (b[(i + n - 1) % pos])) {
		pos = i;
		break;
	}
	if(pos < 0) return cout << "NO" << endl, 0;
	cout << "YES" << endl;
	const i64 oo = 1e18;
	vi64 a(n);
	a[pos] = b[pos];
	i64 k = (oo - sum) / b[pos];
	a[(pos + n - 1) % n] = k * b[pos] + b[(pos + n - 1) % n];
	sum -= b[pos] - b[(pos + n - 1) % n];
	for1(i, n - 2) {
		int x = (pos + n - 1 - i) % n;
		int y = (pos + n - i) % n;
		a[x] = a[y] + b[x];
	}
	for(i64 v : a) cout << v << ' ';
	cout << endl;
#ifdef RICARDO
	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}


#include <bits/stdc++.h>

using namespace std;

#define Cerr cerr << "\nTest: "
#define endl "\n"
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio { ios_base::sync_with_stdio(false), cin.tie(NULL); }
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#ifdef RICARDO
	#define bug(x) cerr << #x << " = " << (x) << endl;
	#define block if(1)
#else
	#define bug(x) "IDINGO"
	#define block if(0)
#endif

template<class T> bool mini(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool maxi(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

//=================================================CODE=================================================//

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
#ifdef RICARDO
	freopen("i", "r", stdin);
#endif
	int n; cin >> n;
	vi64 b(n);
	i64 sum = 0;
	forn(i, n) cin >> b[i], sum += b[i];
	if(sum == 0) {
		cout << "YES" << endl;
		forn(i, n) cout << '1' << ' ';
		cout << endl;
		return 0;
	}
	int pos = -1;
	forn(i, n) if(b[i] > (b[(i + n - 1) % n])) {
		pos = i;
		break;
	}
	if(pos < 0) return cout << "NO" << endl, 0;
	cout << "YES" << endl;
	const i64 oo = 1e18;
	vi64 a(n);
	a[pos] = b[pos];
	i64 k = (oo - sum) / b[pos];
	a[(pos + n - 1) % n] = k * b[pos] + b[(pos + n - 1) % n];
	sum -= b[pos] - b[(pos + n - 1) % n];
	for1(i, n - 2) {
		int x = (pos + n - 1 - i) % n;
		int y = (pos + n - i) % n;
		a[x] = a[y] + b[x];
	}
	for(i64 v : a) cout << v << ' ';
	cout << endl;
#ifdef RICARDO
	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}


#include <bits/stdc++.h>

using namespace std;

#define Cerr cerr << "\nTest: "
#define endl "\n"
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio { ios_base::sync_with_stdio(false), cin.tie(NULL); }
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#ifdef RICARDO
	#define bug(x) cerr << #x << " = " << (x) << endl;
	#define block if(1)
#else
	#define bug(x) "IDINGO"
	#define block if(0)
#endif

template<class T> bool mini(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool maxi(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

//=================================================CODE=================================================//

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
#ifdef RICARDO
	freopen("i", "r", stdin);
#endif
	int n; cin >> n;
	vi64 b(n);
	i64 sum = 0;
	forn(i, n) cin >> b[i], sum += b[i];
	if(sum == 0) {
		forn(i, n) cout << '1' << ' ';
		cout << endl;
		return 0;
	}
	int pos = -1;
	forn(i, n) if(b[i] > (b[(i + n - 1) % n])) {
		pos = i;
		break;
	}
	if(pos < 0) return cout << "NO" << endl, 0;
	cout << "YES" << endl;
	const i64 oo = 1e18;
	vi64 a(n);
	a[pos] = b[pos];
	i64 k = (oo - sum) / b[pos];
	a[(pos + n - 1) % n] = k * b[pos] + b[(pos + n - 1) % n];
	sum -= b[pos] - b[(pos + n - 1) % n];
	for1(i, n - 2) {
		int x = (pos + n - 1 - i) % n;
		int y = (pos + n - i) % n;
		a[x] = a[y] + b[x];
	}
	for(i64 v : a) cout << v << ' ';
	cout << endl;
#ifdef RICARDO
	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}


#include <bits/stdc++.h>

using namespace std;

#define Cerr cerr << "\nTest: "
#define endl "\n"
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio { ios_base::sync_with_stdio(false), cin.tie(NULL); }
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#ifdef RICARDO
	#define bug(x) cerr << #x << " = " << (x) << endl;
	#define block if(1)
#else
	#define bug(x) "IDINGO"
	#define block if(0)
#endif

template<class T> bool mini(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool maxi(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

//=================================================CODE=================================================//

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
#ifdef RICARDO
	freopen("i", "r", stdin);
#endif
	int n; cin >> n;
	vi64 b(n);
	i64 sum = 0;
	forn(i, n) cin >> b[i], sum += b[i];
	int pos = -1;
	forn(i, n) if(b[i] > (b[(i + n - 1) % n])) {
		pos = i;
		break;
	}
	if(pos < 0) return cout << "NO" << endl, 0;
	cout << "YES" << endl;
	const i64 oo = 1e18;
	vi64 a(n);
	a[pos] = b[pos];
	i64 k = (oo - sum) / b[pos];
	a[(pos + n - 1) % n] = k * b[pos] + b[(pos + n - 1) % n];
	sum -= b[pos] - b[(pos + n - 1) % n];
	for1(i, n - 2) {
		int x = (pos + n - 1 - i) % n;
		int y = (pos + n - i) % n;
		a[x] = a[y] + b[x];
	}
	for(i64 v : a) cout << v << ' ';
	cout << endl;
#ifdef RICARDO
	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}


#include <bits/stdc++.h>
#include <stdint.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/rope>
#define int int_fast64_t
#define double long double

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef pair<int, int> pii;
typedef vector<int> VI;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, j, k, v) for(int (i) = (j)-((v)<0); (v)>0 ? (i)<(k) : (i)>=(k); (i) += (v))
#define REP(i, j, k) for(int (i) = (j); (i) < (k); ++(i))
#define VIS(x, y) for(__typeof(y.begin()) x = y.begin(); x != y.end(); ++x)
#define MST(x, y) memset((x), (y), sizeof(x))
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define endl '\n'

// #define _DEBUG_ //

#ifdef _DEBUG_
	#define de(...) cout << __VA_ARGS__
    #define ar(x, s, t) { REP(_i_, (s), (t)) cout << (x)[_i_] << ' '; cout << endl; }
	#define IOS() (void)0
#else
	#define de(...) (void)0
    #define ar(...) (void)0
	#define IOS() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); }
#endif

const int maxn = 1e5;
int n, m = 0;
int a[maxn], b[maxn];

main() {
	IOS();
	cin >> n;
	FOR(i, n, 0, -1) cin >> b[i], m = max(m, b[i]);
	REP(i, 0, n) if(b[i] == m && b[(i+1) % n] != m) {
		cout << "YES\n";
		a[i] = b[i];
		REP(j, 1, n) a[(i+j) % n] = a[(i+j-1) % n] * (1 + (a[(i+j-1) % n] == b[(i+j) % n])) + b[(i+j) % n];
		FOR(j, n, 0, -1) cout << a[j] << (j ? '\n' : ' ');
		return 0;
	}
	cout << "NO\n";
}


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

using namespace std;

#define FOR(i, j, k) for(int (i) = (j) - 1; (i) >= (k); --(i))
#define REP(i, j, k) for(int (i) = (j); (i) < (k); ++(i))
#define MST(x, y) memset((x), (y), sizeof(x))
#define IOS() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); }

int n, m = 0, ok = 0;
int a[150000];

main() {
	IOS();
	cin >> n;
	FOR(i, n, 0) cin >> a[i], m = max(m, a[i]);
	REP(i, 0, n) if(a[i] == m && a[(i+1) % n] != m) {
		ok = 1;
		REP(j, 1, n) {
			#define cur (i+j) % n
			a[cur] += a[(i+j-1) % n];
			if(a[cur] == a[(i+j+1) % n]) a[cur] <<= 1;
		}
		break;
	}
	if(!ok && !a[0]) ok = 1, fill(a, a + n, 1);
	if(ok) {
		cout << "YES\n";
		FOR(j, n, 0) cout << a[j] << (j ? ' ' : '\n');
	}
	else cout << "NO\n";
}


#include <bits/stdc++.h>
#include <stdint.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/rope>
#define int int_fast64_t
#define double long double

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef pair<int, int> pii;
typedef vector<int> VI;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, j, k, v) for(int (i) = (j)-((v)<0); (v)>0 ? (i)<(k) : (i)>=(k); (i) += (v))
#define REP(i, j, k) for(int (i) = (j); (i) < (k); ++(i))
#define VIS(x, y) for(__typeof(y.begin()) x = y.begin(); x != y.end(); ++x)
#define MST(x, y) memset((x), (y), sizeof(x))
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define endl '\n'

// #define _DEBUG_ //

#ifdef _DEBUG_
	#define de(...) cout << __VA_ARGS__
    #define ar(x, s, t) { REP(_i_, (s), (t)) cout << (x)[_i_] << ' '; cout << endl; }
	#define IOS() (void)0
#else
	#define de(...) (void)0
    #define ar(...) (void)0
	#define IOS() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); }
#endif

const int maxn = 1e5;
int n, m = 0, ok = 0;
int a[maxn], b[maxn];

main() {
	IOS();
	cin >> n;
	FOR(i, n, 0, -1) cin >> b[i], m = max(m, b[i]);
	REP(i, 0, n) if(b[i] == m && b[(i+1) % n] != m) {
		ok = 1, a[i] = b[i];
		REP(j, 1, n) a[(i+j) % n] = a[(i+j-1) % n] * (1 + (a[(i+j-1) % n] == b[(i+j) % n])) + b[(i+j) % n];
	}
	if(!ok && !b[0]) MST(a, 0), ok = 1;
	if(ok) {
		cout << "YES\n";
		FOR(j, n, 0, -1) cout << a[j] << (j ? '\n' : ' ');
	}
	else cout << "NO\n";
}


#include <bits/stdc++.h>
#include <stdint.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/rope>
#define int int_fast64_t
#define double long double

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef pair<int, int> pii;
typedef vector<int> VI;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, j, k, v) for(int (i) = (j)-((v)<0); (v)>0 ? (i)<(k) : (i)>=(k); (i) += (v))
#define REP(i, j, k) for(int (i) = (j); (i) < (k); ++(i))
#define VIS(x, y) for(__typeof(y.begin()) x = y.begin(); x != y.end(); ++x)
#define MST(x, y) memset((x), (y), sizeof(x))
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define endl '\n'

// #define _DEBUG_ //

#ifdef _DEBUG_
	#define de(...) cout << __VA_ARGS__
    #define ar(x, s, t) { REP(_i_, (s), (t)) cout << (x)[_i_] << ' '; cout << endl; }
	#define IOS() (void)0
#else
	#define de(...) (void)0
    #define ar(...) (void)0
	#define IOS() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); }
#endif

const int maxn = 1e5;
int n, m = 0, ok = 0;
int a[maxn], b[maxn];

main() {
	IOS();
	cin >> n;
	FOR(i, n, 0, -1) cin >> b[i], m = max(m, b[i]);
	REP(i, 0, n) if(b[i] == m && b[(i+1) % n] != m) {
		ok = 1, a[i] = b[i];
		REP(j, 1, n) {
			a[(i+j) % n] = a[(i+j-1) % n] + b[(i+j) % n];
			if(a[(i+j) % n] == b[(i+j+1) % n]) a[(i+j) % n] <<= 1;
		}
	}
	if(!ok && !b[0]) fill(a, a + n, 1), ok = 1;
	if(ok) {
		cout << "YES\n";
		FOR(j, n, 0, -1) cout << a[j] << (j ? ' ' : '\n');
	}
	else cout << "NO\n";
}


#include <bits/stdc++.h>
#include <stdint.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/rope>
#define int int_fast64_t
#define double long double

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef pair<int, int> pii;
typedef vector<int> VI;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, j, k, v) for(int (i) = (j)-((v)<0); (v)>0 ? (i)<(k) : (i)>=(k); (i) += (v))
#define REP(i, j, k) for(int (i) = (j); (i) < (k); ++(i))
#define VIS(x, y) for(__typeof(y.begin()) x = y.begin(); x != y.end(); ++x)
#define MST(x, y) memset((x), (y), sizeof(x))
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define endl '\n'

// #define _DEBUG_ //

#ifdef _DEBUG_
	#define de(...) cout << __VA_ARGS__
    #define ar(x, s, t) { REP(_i_, (s), (t)) cout << (x)[_i_] << ' '; cout << endl; }
	#define IOS() (void)0
#else
	#define de(...) (void)0
    #define ar(...) (void)0
	#define IOS() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); }
#endif

const int maxn = 2e5;
int n, m = 0, ok = 0;
int a[maxn], b[maxn];

main() {
	IOS();
	cin >> n;
	FOR(i, n, 0, -1) cin >> b[i], m = max(m, b[i]);
	REP(i, 0, n) if(b[i] == m && b[(i+1) % n] != m) {
		ok = 1, a[i] = b[i];
		REP(j, 1, n) {
			a[(i+j) % n] = a[(i+j-1) % n] + b[(i+j) % n];
			if(a[(i+j) % n] == b[(i+j+1) % n]) a[(i+j) % n] <<= 1;
		}
	}
	if(!ok && !b[0]) fill(a, a + n, 1), ok = 1;
	if(ok) {
		cout << "YES\n";
		FOR(j, n, 0, -1) cout << a[j] << (j ? ' ' : '\n');
	}
	else cout << "NO\n";
}


#include <bits/stdc++.h>
#include <stdint.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/rope>
#define int int_fast64_t
#define double long double

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef pair<int, int> pii;
typedef vector<int> VI;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, j, k, v) for(int (i) = (j)-((v)<0); (v)>0 ? (i)<(k) : (i)>=(k); (i) += (v))
#define REP(i, j, k) for(int (i) = (j); (i) < (k); ++(i))
#define VIS(x, y) for(__typeof(y.begin()) x = y.begin(); x != y.end(); ++x)
#define MST(x, y) memset((x), (y), sizeof(x))
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define endl '\n'

// #define _DEBUG_ //

#ifdef _DEBUG_
	#define de(...) cout << __VA_ARGS__
    #define ar(x, s, t) { REP(_i_, (s), (t)) cout << (x)[_i_] << ' '; cout << endl; }
	#define IOS() (void)0
#else
	#define de(...) (void)0
    #define ar(...) (void)0
	#define IOS() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); }
#endif

const int maxn = 2e5;
int n, m = 0, ok = 0;
int a[maxn], b[maxn];

main() {
	IOS();
	cin >> n;
	FOR(i, n, 0, -1) cin >> b[i], m = max(m, b[i]);
	REP(i, 0, n) if(b[i] == m && b[(i+1) % n] != m) {
		ok = 1, a[i] = b[i];
		REP(j, 1, n) {
			a[(i+j) % n] = a[(i+j-1) % n] + b[(i+j) % n];
			if(a[(i+j) % n] == b[(i+j+1) % n]) a[(i+j) % n] <<= 1;
		}
		break;
	}
	if(!ok && !b[0]) fill(a, a + n, 1), ok = 1;
	if(ok) {
		cout << "YES\n";
		FOR(j, n, 0, -1) cout << a[j] << (j ? ' ' : '\n');
	}
	else cout << "NO\n";
}


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

using namespace std;

#define REP(i, j, k) for(int (i) = (j); (i) < (k); ++(i))

int n, m = 0, ok = 0;
int a[150000];

main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cin >> n;
	REP(i, 0, n) cin >> a[n-1-i], m = max(m, a[n-1-i]);
	REP(i, 0, n) if(a[i] == m && a[(i+1) % n] != m) {
		ok = 1;
		REP(j, 1, n) {
			a[(i+j) % n] += a[(i+j-1) % n];
			if(a[(i+j) % n] == a[(i+j+1) % n]) a[(i+j) % n] <<= 1;
		}
		break;
	}
	if(!ok && !a[0]) ok = 1, fill(a, a + n, 1);
	if(ok) {
		cout << "YES\n";
		REP(j, 0, n) cout << a[n-1-j] << (n-1-j ? ' ' : '\n');
	}
	else cout << "NO\n";
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
#define REP(i,j,k) for(int i=j;i<k;++i)
int n,m,ok;
int a[150000];
main(){
	cin>>n;
	REP(i, 0, n)cin>>a[n-1-i], m=max(m,a[n-1-i]);
	REP(i,0,n)if(!ok&&a[i]==m&&a[(i+1)%n]!=m)REP(j,1,n){
		ok=1,a[(i+j)%n]+=a[(i+j-1)%n];
		if(a[(i+j)%n]==a[(i+j+1)%n])a[(i+j)%n]<<=1;
	}
	if(!ok&&!a[0])ok=1,fill(a,a+n,1);
	if(ok){
		cout<<"YES\n";
		REP(j,0,n) cout<<a[n-1-j]<<' ';
	}
	else cout<<"NO\n";
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
#define REP(i,j,k) for(int i=j;i<k;++i)
int n,m,ok;
int a[150000];
main() {
	cin>>n;
	REP(i, 0, n)cin>>a[n-1-i], m=max(m,a[n-1-i]);
	REP(i,0,n)if(!ok&&a[i]==m&&a[(i+1)%n]!=m)REP(j,1,n){
		ok=1,a[(i+j)%n]+=a[(i+j-1)%n];
		if(a[(i+j)%n]==a[(i+j+1)%n])a[(i+j)%n]<<=1;
	}
	if(!ok&&!a[0])ok=1,fill(a,a+n,1);
	if(ok){
		cout << "YES\n";
		REP(j,0,n) cout<<a[n-1-j]<<(n-1-j?' ':'\n');
	}
	else cout<<"NO\n";
}


#include <bits/stdc++.h>
#include <stdint.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/rope>
#define int int_fast64_t
#define double long double

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef pair<int, int> pii;
typedef vector<int> VI;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, j, k, v) for(int (i) = (j)-((v)<0); (v)>0 ? (i)<(k) : (i)>=(k); (i) += (v))
#define REP(i, j, k) for(int (i) = (j); (i) < (k); ++(i))
#define VIS(x, y) for(__typeof(y.begin()) x = y.begin(); x != y.end(); ++x)
#define MST(x, y) memset((x), (y), sizeof(x))
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define endl '\n'

// #define _DEBUG_ //

#ifdef _DEBUG_
	#define de(...) cout << __VA_ARGS__
    #define ar(x, s, t) { REP(_i_, (s), (t)) cout << (x)[_i_] << ' '; cout << endl; }
	#define IOS() (void)0
#else
	#define de(...) (void)0
    #define ar(...) (void)0
	#define IOS() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); }
#endif

const int maxn = 1e5;
int n, m = 0, ok = 0;
int a[maxn], b[maxn];

main() {
	IOS();
	cin >> n;
	FOR(i, n, 0, -1) cin >> b[i], m = max(m, b[i]);
	REP(i, 0, n) if(b[i] == m && b[(i+1) % n] != m) {
		ok = 1, a[i] = b[i];
		REP(j, 1, n) a[(i+j) % n] = a[(i+j-1) % n] * (1 + (a[(i+j-1) % n] == b[(i+j) % n])) + b[(i+j) % n];
	}
	if(!ok && !b[0]) fill(a, a + n, 1), ok = 1;
	if(ok) {
		cout << "YES\n";
		FOR(j, n, 0, -1) cout << a[j] << (j ? '\n' : ' ');
	}
	else cout << "NO\n";
}


#include <bits/stdc++.h>
#include <stdint.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/rope>
#define int int_fast64_t
#define double long double

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef pair<int, int> pii;
typedef vector<int> VI;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, j, k, v) for(int (i) = (j)-((v)<0); (v)>0 ? (i)<(k) : (i)>=(k); (i) += (v))
#define REP(i, j, k) for(int (i) = (j); (i) < (k); ++(i))
#define VIS(x, y) for(__typeof(y.begin()) x = y.begin(); x != y.end(); ++x)
#define MST(x, y) memset((x), (y), sizeof(x))
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define endl '\n'

// #define _DEBUG_ //

#ifdef _DEBUG_
	#define de(...) cout << __VA_ARGS__
    #define ar(x, s, t) { REP(_i_, (s), (t)) cout << (x)[_i_] << ' '; cout << endl; }
	#define IOS() (void)0
#else
	#define de(...) (void)0
    #define ar(...) (void)0
	#define IOS() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); }
#endif

const int maxn = 1e5;
int n, m = 0, ok = 0;
int a[maxn], b[maxn];

main() {
	IOS();
	cin >> n;
	FOR(i, n, 0, -1) cin >> b[i], m = max(m, b[i]);
	REP(i, 0, n) if(b[i] == m && b[(i+1) % n] != m) {
		ok = 1, a[i] = b[i];
		REP(j, 1, n) a[(i+j) % n] = a[(i+j-1) % n] * (1 + (a[(i+j-1) % n] == b[(i+j) % n])) + b[(i+j) % n];
	}
	if(b[0] == 0) MST(a, 0), ok = 1;
	if(ok) {
		cout << "YES\n";
		FOR(j, n, 0, -1) cout << a[j] << (j ? '\n' : ' ');
	}
	else cout << "NO\n";
}


#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long

/*
    a1 ... an
    b1 ... bn

    bi = ai mod ai+1
    ai = bi + (ai+1)*k

    두 개일 때
    a1 = b1 + a2*k1
    a2 = b2 + a1*k2

    결국 양수라면, 크기 순서가 있을 것이다.
    뒤에거보다 작은 놈은 그대로이다.
    뒤에거보다 큰놈은 뒤에것으로 나눈 나머지이다.

    모두 같은 수 일 때 불가능
    a<b 인 시점을 하나 잡고
    거기서 부터 앞으로 나가면서
    a = a+b로 변화시키면서 구해보자
    만약 c>k인 시점이 온다면, k가 c보다 크도록 a +b*alpha를 하자
*/

int main(){
    int n=0;
    cin>>n;
    vector<ll> vl(n,0);
    bool check = true;
    int start = -1;

    scanf("%d", &vl[0]);
    for(int i=1; i<n; i++){
        scanf("%d", &vl[i]);
        if(check && vl[i-1] < vl[i]){
            check = false;
            start = i;
        }
    }

    if(check){
        cout<<"NO";
        return 0;
    }

    int now = start - 1;
    int mul = 190000/vl[start] + ( (190000%vl[start] > 0) ? 1 : 0);
    vl[now] = vl[start] * mul +vl[now];
    while(now!= start){
        int next = (now+n-1)%n;
        if(next == start)
        break;
        vl[next] = vl[next] + vl[now];
        now = next;
    }

    cout<<"YES\n";
    for(int i=0; i<n; i++){
        printf("%d ", vl[i]);
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long

/*
    a1 ... an
    b1 ... bn

    bi = ai mod ai+1
    ai = bi + (ai+1)*k

    두 개일 때
    a1 = b1 + a2*k1
    a2 = b2 + a1*k2

    결국 양수라면, 크기 순서가 있을 것이다.
    뒤에거보다 작은 놈은 그대로이다.
    뒤에거보다 큰놈은 뒤에것으로 나눈 나머지이다.

    모두 같은 수 일 때 불가능
    a<b 인 시점을 하나 잡고
    거기서 부터 앞으로 나가면서
    a = a+b로 변화시키면서 구해보자
    만약 c>k인 시점이 온다면, k가 c보다 크도록 a +b*alpha를 하자
*/

int main(){
    int n=0;
    cin>>n;
    vector<ll> vl(n,0);
    bool check = true;
    int start = -1;

    scanf("%d", &vl[0]);
    for(int i=1; i<n; i++){
        scanf("%d", &vl[i]);
        if(check && vl[i-1] < vl[i]){
            check = false;
            start = i;
        }
    }

    if(check && vl[n-1] < vl[0]){
        check = false;
        start = 0;
    }

    if(check && vl[0] == 0){
        cout<<"YES\n";
        for(int i=0; i<n; i++){
            printf("%d ", 1);
        }
        return 0;
    }

    if(check){
        cout<<"NO";
        return 0;
    }

    int now = (start + n- 1)%n;
    int mul = 190000/vl[start] + ( (190000%vl[start] > 0) ? 1 : 0);
    vl[now] = vl[start] * mul +vl[now];
    while(now!= start){
        int next = (now+n-1)%n;
        if(next == start){
            break;
        }
        vl[next] = vl[next] + vl[now];
        now = next;
    }

    cout<<"YES\n";
    for(int i=0; i<n; i++){
        printf("%d ", vl[i]);
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long

/*
    a1 ... an
    b1 ... bn

    bi = ai mod ai+1
    ai = bi + (ai+1)*k

    두 개일 때
    a1 = b1 + a2*k1
    a2 = b2 + a1*k2

    결국 양수라면, 크기 순서가 있을 것이다.
    뒤에거보다 작은 놈은 그대로이다.
    뒤에거보다 큰놈은 뒤에것으로 나눈 나머지이다.

    모두 같은 수 일 때 불가능
    a<b 인 시점을 하나 잡고
    거기서 부터 앞으로 나가면서
    a = a+b로 변화시키면서 구해보자
    만약 c>k인 시점이 온다면, k가 c보다 크도록 a +b*alpha를 하자
*/

int main(){
    int n=0;
    cin>>n;
    vector<ll> vl(n,0);
    bool check = true;
    int start = -1;

    scanf("%d", &vl[0]);
    for(int i=1; i<n; i++){
        scanf("%d", &vl[i]);
        if(check && vl[i-1] < vl[i]){
            check = false;
            start = i;
        }
    }

    if(check && vl[n-1] < vl[0]){
        check = false;
        start = 0;
    }

    if(check && vl[0] == 0){
        cout<<"YES\n";
        for(int i=0; i<n; i++){
            printf("%d ", 1);
        }
        return 0;
    }

    if(check){
        cout<<"NO";
        return 0;
    }

    ll now = (start + n- 1)%n;
    ll mul = 190000/vl[start] + ( (190000%vl[start] > 0) ? 1 : 0);
    vl[now] = vl[start] * mul +vl[now];
    while(now!= start){
        ll next = (now+n-1)%n;
        if(next == start){
            break;
        }
        vl[next] = vl[next] + vl[now];
        now = next;
    }

    cout<<"YES\n";
    for(int i=0; i<n; i++){
        printf("%lld ", vl[i]);
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long

/*
    a1 ... an
    b1 ... bn

    bi = ai mod ai+1
    ai = bi + (ai+1)*k

    두 개일 때
    a1 = b1 + a2*k1
    a2 = b2 + a1*k2

    결국 양수라면, 크기 순서가 있을 것이다.
    뒤에거보다 작은 놈은 그대로이다.
    뒤에거보다 큰놈은 뒤에것으로 나눈 나머지이다.

    모두 같은 수 일 때 불가능
    a<b 인 시점을 하나 잡고
    거기서 부터 앞으로 나가면서
    a = a+b로 변화시키면서 구해보자
    만약 c>k인 시점이 온다면, k가 c보다 크도록 a +b*alpha를 하자
*/

int main(){
    int n=0;
    cin>>n;
    vector<ll> vl(n,0);
    bool check = true;
    int start = -1;

    scanf("%d", &vl[0]);
    for(int i=1; i<n; i++){
        scanf("%d", &vl[i]);
        if(check && vl[i-1] < vl[i]){
            check = false;
            start = i;
        }
    }

    if(check && vl[n-1] < vl[0]){
        check = false;
        start = 0;
    }

    if(check){
        cout<<"NO";
        return 0;
    }

    int now = (start + n- 1)%n;
    int mul = 190000/vl[start] + ( (190000%vl[start] > 0) ? 1 : 0);
    vl[now] = vl[start] * mul +vl[now];
    while(now!= start){
        int next = (now+n-1)%n;
        if(next == start)
        break;
        vl[next] = vl[next] + vl[now];
        now = next;
    }

    cout<<"YES\n";
    for(int i=0; i<n; i++){
        printf("%d ", vl[i]);
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long

/*
    a1 ... an
    b1 ... bn

    bi = ai mod ai+1
    ai = bi + (ai+1)*k

    두 개일 때
    a1 = b1 + a2*k1
    a2 = b2 + a1*k2

    결국 양수라면, 크기 순서가 있을 것이다.
    뒤에거보다 작은 놈은 그대로이다.
    뒤에거보다 큰놈은 뒤에것으로 나눈 나머지이다.

    모두 같은 수 일 때 불가능
    a<b 인 시점을 하나 잡고
    거기서 부터 앞으로 나가면서
    a = a+b로 변화시키면서 구해보자
    만약 c>k인 시점이 온다면, k가 c보다 크도록 a +b*alpha를 하자
*/

int main(){
    int n=0;
    cin>>n;
    vector<ll> vl(n,0);
    bool check = true;
    int start = -1;

    scanf("%d", &vl[0]);
    for(int i=1; i<n; i++){
        scanf("%d", &vl[i]);
        if(check && vl[i-1] < vl[i]){
            check = false;
            start = i;
        }
    }

    if(check && vl[n-1] < vl[0]){
        check = false;
        start = 0;
    }

    if(check && vl[0] == 0){
        cout<<"YES\n";
        for(int i=0; i<n; i++){
            printf("%d ", 1);
        }
        return 0;
    }

    if(check){
        cout<<"NO";
        return 0;
    }

    int now = (start + n- 1)%n;
    int mul = 190000/vl[start] + ( (190000%vl[start] > 0) ? 1 : 0);
    vl[now] = vl[start] * mul +vl[now];
    while(now!= start){
        int next = (now+n-1)%n;
        if(next == start)
        break;
        vl[next] = vl[next] + vl[now];
        now = next;
    }

    cout<<"YES\n";
    for(int i=0; i<n; i++){
        printf("%d ", vl[i]);
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,a[N],b[N],Max;

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if (a[i]>a[Max]) Max=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("1 ");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    Max+=n;
    if (a[Max]==1)
    {
        for (int i=n+1;i<=n<<1;i++) if (a[i]==1&&a[i-1]==0)
        {
            Max=i;
            break;
        }
    }
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        b[i]=b[i+1]+a[i];
        if (b[i]==1&&a[i]==0) b[i]=2;
        if (b[i]%b[i+1]!=a[i])
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    for (int i=Max+1;i<Max+n;i++) b[i]=b[i-n];
    for (int i=n+1;i<=n<<1;i++) printf("%d ",b[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,a[N],b[N],Max;

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if (a[i]>a[Max]) Max=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("0 ");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    Max+=n;
    if (a[Max]==1)
    {
        for (int i=n+1;i<=n<<1;i++) if (a[i]==1&&a[i-1]==0)
        {
            Max=i;
            break;
        }
    }
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        b[i]=b[i+1]+a[i];
        if (b[i]==1&&a[i]==0) b[i]=2;
        if (b[i]%b[i+1]!=a[i])
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    for (int i=1;i<=n;i++) printf("%d ",b[(i+Max-2)%Max+2]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,Max;
long long a[N],b[N];

int main()
{
    scanf("%d",&n);
    int Min=1;
    for (int i=1;i<=n;i++)
    {
        scanf("%I64d",&a[i]);
        if (a[i]>a[Max]) Max=i;
        if (a[i]<a[Min]) Min=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("1 ");
        return 0;
    }
    if (Min==Max)
    {
        puts("NO");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    Max+=n;
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        if (i==Max-1) b[i]=b[i+1]*2+a[i];
        else b[i]=b[i+1]+a[i];
        if (b[i]<=1&&a[i]==0) b[i]=2;
    }
    puts("YES");
    for (int i=Max+1;i<Max+n;i++) b[i]=b[i-n];
    for (int i=n+1;i<=n<<1;i++) printf("%I64d ",b[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,Max;
long long a[N],b[N];

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%I64d",&a[i]);
        if (a[i]>a[Max]) Max=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("1 ");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    Max+=n;
    if (a[Max]==1)
    {
        for (int i=n+1;i<=n<<1;i++) if (a[i]==1&&a[i-1]==0)
        {
            Max=i;
            break;
        }
    }
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        b[i]=b[i+1]+a[i];
        if (b[i]<=1&&a[i]==0) b[i]=2;
        if (b[i]%b[i+1]!=a[i])
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    for (int i=Max+1;i<Max+n;i++) b[i]=b[i-n];
    for (int i=n+1;i<=n<<1;i++) printf("%I64d ",b[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,Max;
long long a[N],b[N];

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%I64d",&a[i]);
        if (a[i]>a[Max]) Max=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("1 ");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    Max+=n;
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        if (i==Max-1) b[i]=b[i+1]*2+a[i];
        else b[i]=b[i+1]+a[i];
        if (b[i]<=1&&a[i]==0) b[i]=2;
        if (b[i]%b[i+1]!=a[i])
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    for (int i=Max+1;i<Max+n;i++) b[i]=b[i-n];
    for (int i=n+1;i<=n<<1;i++) printf("%I64d ",b[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,Max;
long long a[N],b[N];

int main()
{
    scanf("%d",&n);
    int Min=1;
    for (int i=1;i<=n;i++)
    {
        scanf("%I64d",&a[i]);
        if (a[i]>a[Max]) Max=i;
        if (a[i]<a[Min]) Min=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("1 ");
        return 0;
    }
    if (Min==Max)
    {
        puts("NO");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    for (int i=n+1;i<=n<<1;i++) if (a[i]!=a[i-1]&&a[i]==a[Max]) Max=i;
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        if (i==Max-1) b[i]=b[i+1]*2+a[i];
        else b[i]=b[i+1]+a[i];
        if (b[i]<=1&&a[i]==0) b[i]=2;
    }
    puts("YES");
    for (int i=Max+1;i<Max+n;i++) b[i]=b[i-n];
    for (int i=n+1;i<=n<<1;i++) printf("%I64d ",b[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,a[N],b[N],Max;

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if (a[i]>a[Max]) Max=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("0 ");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    Max+=n;
    if (a[Max]==1)
    {
        for (int i=n+1;i<=n<<1;i++) if (a[i]==1&&a[i-1]==0)
        {
            Max=i;
            break;
        }
    }
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        b[i]=b[i+1]+a[i];
        if (b[i]==1&&a[i]==0) b[i]=2;
        if (b[i]%b[i+1]!=a[i])
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    for (int i=1;i<=n;i++) printf("%d ",b[(i+n-1)%Max+1]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,a[N],b[N],Max;

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if (a[i]>a[Max]) Max=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("0 ");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    Max+=n;
    if (a[Max]==1)
    {
        for (int i=n+1;i<=n<<1;i++) if (a[i]==1&&a[i-1]==0)
        {
            Max=i;
            break;
        }
    }
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        b[i]=b[i+1]+a[i];
        if (b[i]==1&&a[i]==0) b[i]=2;
        if (b[i]%b[i+1]!=a[i])
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    for (int i=1;i<=n;i++) printf("%d ",b[(i+Max-2)%Max+1]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,a[N],b[N],Max;

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if (a[i]>a[Max]) Max=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("0 ");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    Max+=n;
    if (a[Max]==1)
    {
        for (int i=n+1;i<=n<<1;i++) if (a[i]==1&&a[i-1]==0)
        {
            Max=i;
            break;
        }
    }
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        b[i]=b[i+1]+a[i];
        if (b[i]==1&&a[i]==0) b[i]=2;
        if (b[i]%b[i+1]!=a[i])
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    for (int i=Max+1;i<Max+n;i++) b[i]=b[i-n];
    for (int i=n+1;i<=n<<1;i++) printf("%d ",b[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,a[N],b[N],Max;

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if (a[i]>a[Max]) Max=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("0 ");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    Max+=n;
    if (a[Max]==1)
    {
        for (int i=n+1;i<=n<<1;i++) if (a[i]==1&&a[i-1]==0)
        {
            Max=i;
            break;
        }
    }
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        b[i]=b[i+1]+a[i];
        if (b[i]==1&&a[i]==0) b[i]=2;
        if (b[i]%b[i+1]!=a[i])
        {
            puts("NO");
            return 0;
        }
    }
    for (int i=Max+1;i<Max+n;i++) b[i]=b[i-n];
    for (int i=n+1;i<=n<<1;i++) printf("%d ",b[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     N       400005
#define     P       1000000007ll

int i,j,k,l,n,m,a[N],b[N],Max;

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if (a[i]>a[Max]) Max=i;
    }
    if (Max==0)
    {
        puts("YES");
        for (int i=1;i<=n;i++) printf("0 ");
        return 0;
    }
    for (int i=1;i<=n;i++) a[i+n]=a[i];
    Max+=n;
    b[Max]=a[Max];
    for (int i=Max-1;i;i--)
    {
        b[i]=b[i+1]+a[i];
        if (b[i]%b[i+1]!=a[i])
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    for (int i=1;i<=n;i++) printf("%d ",b[(i+n-1)%Max+1]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> ii;
#define all(x) x.begin(),x.end()
#define rep(i,x) for(int i=0;i<(x);++i)
#define finc(i,a,b) for(int i=(a);i<=(b);++i)
#define fdec(i,a,b) for(int i=(a);i>=(b);--i)
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back
#define x first
#define y second
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
template <typename T> inline void read(T &x) {
    char c;
    bool neg=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-') neg=1, c=getchar();
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(neg) x=-x;
}
template <typename T> inline void write(T x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+48);
}
#define _ putchar(' ')
#define __ putchar('\n')
// -----------------------------------------------------------
const int N=2e5;
int n,b[N+2],a[N+2];
void ex(){
    cout << "NO";
    exit(0);
}
void check(int pos){
    a[pos]=b[pos];
    for(int x=1;x<n;++x){
        if (pos==1) pos=n; else --pos;
        int pre=pos-1; if (!pre) pre=n;
        int nex=pos%n+1;
        int k;
        k=(b[pre]-b[pos])/a[nex];
        a[pos]=b[pos]+k*a[nex];
        while (a[pos]<b[pre]) a[pos]+=a[nex];
    }
    cout << "YES" << '\n';
    finc(i,1,n) cout << a[i] << ' ';
}
int main(){
    fast_io;
    cin >> n;
    finc(i,1,n) cin >> b[i];
    if (b[1]>b[n]){
        check(1);
        return 0;
    }
    finc(i,2,n) if (b[i]>b[i-1]){
        check(i);
        return 0;
    }
    if (b[1]) ex();
    cout << "YES" << '\n';
    finc(i,1,n) cout << 1 << ' ';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
#define all(x) x.begin(),x.end()
#define rep(i,x) for(ll i=0;i<(x);++i)
#define finc(i,a,b) for(ll i=(a);i<=(b);++i)
#define fdec(i,a,b) for(ll i=(a);i>=(b);--i)
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back
#define x first
#define y second
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
template <typename T> inline void read(T &x) {
    char c;
    bool neg=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-') neg=1, c=getchar();
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(neg) x=-x;
}
template <typename T> inline void write(T x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+48);
}
#define _ putchar(' ')
#define __ putchar('\n')
// -----------------------------------------------------------
const ll N=2e5;
ll n,b[N+2],a[N+2];
void ex(){
    cout << "NO";
    exit(0);
}
void check(ll pos){
    a[pos]=b[pos];
    for(ll x=1;x<n;++x){
        if (pos==1) pos=n; else --pos;
        ll pre=pos-1; if (!pre) pre=n;
        ll nex=pos%n+1;
        ll k;
        k=(b[pre]-b[pos])/a[nex];
        a[pos]=b[pos]+k*a[nex];
        while (a[pos]<=b[pre]) a[pos]+=a[nex];
    }
    cout << "YES" << '\n';
    finc(i,1,n) cout << a[i] << ' ';
}
int main(){
    fast_io;
    cin >> n;
    finc(i,1,n) cin >> b[i];
    if (b[1]>b[n]){
        check(1);
        return 0;
    }
    finc(i,2,n) if (b[i]>b[i-1]){
        check(i);
        return 0;
    }
    if (b[1]) ex();
    cout << "YES" << '\n';
    finc(i,1,n) cout << 1 << ' ';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> ii;
#define all(x) x.begin(),x.end()
#define rep(i,x) for(int i=0;i<(x);++i)
#define finc(i,a,b) for(int i=(a);i<=(b);++i)
#define fdec(i,a,b) for(int i=(a);i>=(b);--i)
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back
#define x first
#define y second
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
template <typename T> inline void read(T &x) {
    char c;
    bool neg=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-') neg=1, c=getchar();
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(neg) x=-x;
}
template <typename T> inline void write(T x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+48);
}
#define _ putchar(' ')
#define __ putchar('\n')
// -----------------------------------------------------------
const int N=2e5;
int n,b[N+2],a[N+2];
void ex(){
    cout << "NO";
    exit(0);
}
void check(int pos){
    a[pos]=b[pos];
    for(int x=1;x<n;++x){
        if (pos==1) pos=n; else --pos;
        int pre=pos-1; if (!pre) pre=n;
        int nex=pos%n+1;
        int k;
        k=(b[pre]-b[pos])/a[nex];
        a[pos]=b[pos]+k*a[nex];
        while (a[pos]<=b[pre]) a[pos]+=a[nex];
    }
    cout << "YES" << '\n';
    finc(i,1,n) cout << a[i] << ' ';
}
int main(){
    fast_io;
    cin >> n;
    finc(i,1,n) cin >> b[i];
    if (b[1]>b[n]){
        check(1);
        return 0;
    }
    finc(i,2,n) if (b[i]>b[i-1]){
        check(i);
        return 0;
    }
    if (b[1]) ex();
    cout << "YES" << '\n';
    finc(i,1,n) cout << 1 << ' ';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> ii;
#define all(x) x.begin(),x.end()
#define rep(i,x) for(int i=0;i<(x);++i)
#define finc(i,a,b) for(int i=(a);i<=(b);++i)
#define fdec(i,a,b) for(int i=(a);i>=(b);--i)
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back
#define x first
#define y second
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
template <typename T> inline void read(T &x) {
    char c;
    bool neg=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-') neg=1, c=getchar();
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(neg) x=-x;
}
template <typename T> inline void write(T x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+48);
}
#define _ putchar(' ')
#define __ putchar('\n')
// -----------------------------------------------------------
const int N=2e5;
int n,b[N+2],a[N+2];
void ex(){
    cout << "NO";
    exit(0);
}
void check(int pos){
    a[pos]=b[pos];
    for(int x=1;x<n;++x){
        if (pos==1) pos=n; else --pos;
        int pre=pos-1; if (!pre) pre=n;
        int nex=pos%n+1;
        int k;
        k=(b[pre]-b[pos])/a[nex];
        if ((b[pre]-b[pos])%a[nex]==0) ++k;
        a[pos]=b[pos]+k*a[nex];
    }
    cout << "YES" << '\n';
    finc(i,1,n) cout << a[i] << ' ';
}
int main(){
    fast_io;
    read(n);
    finc(i,1,n) read(b[i]);
    if (b[1]>b[n]){
        check(1);
        return 0;
    }
    finc(i,2,n) if (b[i]>b[i-1]){
        check(i);
        return 0;
    }
    if (b[1]) ex();
    cout << "YES" << '\n';
    finc(i,1,n) cout << 1 << ' ';
    return 0;
}


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

#define LL long long
const int maxn = 200000 + 100;
int n;
int num[maxn];
LL ans[maxn];

bool judge() {
    for(int i = 0; i < n; ++i) {
        int ii = (i + 1) % n;
        if(ans[i] % ans[ii] != num[i]) {
            return false;
        }
    }
    return true;
}

int main() {
    #ifdef Dmaxiya
    freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // Dmaxiya
    ios::sync_with_stdio(false);

    while(scanf("%d", &n) != EOF) {
        for(int i = 0; i < n; ++i) {
            scanf("%d", &num[i]);
        }
        int Index = 0;
        for(int i = 0; i < n; ++i) {
            int ii = (i - 1 + n) % n;
            if(num[i] > num[Index]) {
                Index = i;
            } else if(num[i] == num[Index] && num[ii] != num[i]) {
                Index = i;
            }
        }
        if(num[Index] == 0) {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                if(i != 0) {
                    printf(" ");
                }
                printf("1");
            }
            printf("\n");
            continue;
        }
        ans[Index] = num[Index] * 2;
        int I = (Index - 1 + n) % n;
        while(I != Index) {
            ans[I] = ans[(I + 1) % n] + num[I];
            I = (I - 1 + n) % n;
        }
        ans[Index] = num[Index];
        if(judge()) {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                if(i != 0) {
                    printf(" ");
                }
                printf("%I64d", ans[i]);
            }
            printf("\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}


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

#define LL long long
const int maxn = 200000 + 100;
int n;
int num[maxn];
LL ans[maxn];

bool judge() {
    for(int i = 0; i < n; ++i) {
        if(ans[i] % ans[(i + 1) % n] != num[i]) {
            return false;
        }
    }
    return true;
}

int main() {
    #ifdef Dmaxiya
    freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // Dmaxiya
    ios::sync_with_stdio(false);

    while(scanf("%d", &n) != EOF) {
        memset(ans, 0, sizeof(LL) * n);
        int Max = 0;
        int Index = 0;
        for(int i = 0; i < n; ++i) {
            scanf("%d", &num[i]);
            Max = max(Max, num[i]);
            if(num[i] > num[Index]) {
                Index = i;
            }
        }
        for(int i = 0; i < n; ++i) {
            if(num[i] == Max && num[(i - 1 + n) % n] < Max) {
                Index = i;
            }
        }
        ans[Index] = num[Index];
        int i = Index;
        int ii = (i - 1 + n) % n;
        while(ii != Index) {
            ans[ii] = num[ii] + ans[i];
            i = ii;
            ii = (i - 1 + n) % n;
        }
        if(judge()) {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                if(i != 0) {
                    printf(" ");
                }
                printf("%I64d", ans[i]);
            }
            printf("\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}


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

#define LL long long
const int maxn = 200000 + 100;
int n;
int num[maxn];
LL ans[maxn];

bool judge() {
    for(int i = 0; i < n; ++i) {
        if(ans[i] % ans[(i + 1) % n] != num[i]) {
            return false;
        }
    }
    return true;
}

int main() {
    #ifdef Dmaxiya
    freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // Dmaxiya
    ios::sync_with_stdio(false);

    while(scanf("%d", &n) != EOF) {
        memset(ans, 0, sizeof(LL) * n);
        int Max = 0;
        int Index = 0;
        for(int i = 0; i < n; ++i) {
            scanf("%d", &num[i]);
            Max = max(Max, num[i]);
            if(num[i] > num[Index]) {
                Index = i;
            }
        }
        if(Max == 0) {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                if(i != 0) {
                    printf(" ");
                }
                printf("1");
            }
            printf("\n");
            continue;
        }
        for(int i = 0; i < n; ++i) {
            if(num[i] == Max && num[(i - 1 + n) % n] < Max) {
                Index = i;
            }
        }
        ans[Index] = num[Index];
        int i = Index;
        int ii = (i - 1 + n) % n;
        while(ii != Index) {
            ans[ii] = num[ii] + ans[i];
            i = ii;
            ii = (i - 1 + n) % n;
        }
        if(judge()) {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                if(i != 0) {
                    printf(" ");
                }
                printf("%I64d", ans[i]);
            }
            printf("\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}


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

#define LL long long
const int maxn = 200000 + 100;
int n;
int num[maxn];
LL ans[maxn];

bool judge() {
    for(int i = 0; i < n; ++i) {
        if(ans[i] % ans[(i + 1) % n] != num[i]) {
            return false;
        }
    }
    return true;
}

int main() {
    #ifdef Dmaxiya
    freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // Dmaxiya
    ios::sync_with_stdio(false);

    while(scanf("%d", &n) != EOF) {
        memset(ans, 0, sizeof(LL) * n);
        for(int i = 0; i < n; ++i) {
            scanf("%d", &num[i]);
        }
        int Index = 0;
        for(int i = 0; i < n; ++i) {
            if(num[Index] < num[i]) {
                Index = i;
            } else if(num[Index] == num[i] && num[(i - 1 + n) % n] != num[i]) {
                Index = i;
            }
        }
        if(num[Index] == 0) {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                if(i != 0) {
                    printf(" ");
                }
                printf("1");
            }
            printf("\n");
            continue;
        }
        ans[Index] = num[Index];
        int i = Index;
        int ii = (i - 1 + n) % n;
        while(ii != Index) {
            ans[ii] = ans[i] + num[ii];
            i = ii;
            ii = (i - 1 + n) % n;
        }
        for(int i = n - 1; i >= 0; --i) {
            int ii = (i + 1) % n;
            if(ans[i] % ans[ii] != num[i]) {
                ans[ii] += ans[(ii + 1) % n];
                ans[i] = ans[ii] + num[i];
            }
        }
        if(judge()) {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                if(i != 0) {
                    printf(" ");
                }
                printf("%I64d", ans[i]);
            }
            printf("\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}


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

#define LL long long
const int maxn = 200000 + 100;
int n;
int num[maxn];
LL ans[maxn];

bool judge() {
    for(int i = 0; i < n; ++i) {
        if(ans[i] % ans[(i + 1) % n] != num[i]) {
            return false;
        }
    }
    return true;
}

int main() {
    #ifdef Dmaxiya
    freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // Dmaxiya
    ios::sync_with_stdio(false);

    while(scanf("%d", &n) != EOF) {
        memset(ans, 0, sizeof(LL) * n);
        for(int i = 0; i < n; ++i) {
            scanf("%d", &num[i]);
        }
        int Index = 0;
        for(int i = 0; i < n; ++i) {
            if(num[Index] < num[i]) {
                Index = i;
            } else if(num[Index] == num[i] && num[(i - 1 + n) % n] != num[i]) {
                Index = i;
            }
        }
        if(num[Index] == 0) {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                if(i != 0) {
                    printf(" ");
                }
                printf("1");
            }
            printf("\n");
            continue;
        }
        ans[Index] = num[Index];
        int i = Index;
        int ii = (i - 1 + n) % n;
        while(ii != Index) {
            if(ans[ii] == 0) {
                ans[ii] = ans[i] + num[ii];
                if(num[ii] == 0 && num[(ii - 1 + n) % n] == num[Index]) {
                    ans[ii] = 2 * ans[i];
                    ans[(ii - 1 + n) % n] = num[(ii - 1 + n) % n] + ans[ii];
                }
            }
            i = ii;
            ii = (i - 1 + n) % n;
        }
        for(int i = n - 1; i >= 0; --i) {
            int ii = (i + 1) % n;
            if(ans[i] % ans[ii] != num[i]) {
                ans[ii] += ans[(ii + 1) % n];
                ans[i] = ans[ii] + num[i];
            }
        }
        if(judge()) {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                if(i != 0) {
                    printf(" ");
                }
                printf("%I64d", ans[i]);
            }
            printf("\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=200100;
int a[N],n;
ll ans[N];
int main(){
	int i,j,k,fl=0,pos;
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<n;i++)
		if(a[i]!=a[i+1]){
			fl=2;
			break;
		}
		else if(a[i])
			fl=1;
	if(!fl){
		printf("YES\n");
		for(i=1;i<=n;i++)
			printf("1 ");
		printf("\n");
		return 0;
	}
	else if(fl==1){
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	pos=1;
	for(i=2;i<=n;i++)
		if(a[i]>a[pos])
			pos=i;
	if((pos==1)&&(a[n]==a[1]))
		for(pos=n;a[pos]==a[pos-1];pos--);
	ans[pos]=a[pos];
	for(i=pos-1;i;i--)
		ans[i]=ans[i+1]+a[i];
	if(pos!=n)
		ans[n]=ans[1]+a[n];
	for(i=n-1;i>pos;i--)
		ans[i]=ans[i+1]+a[i];
	for(i=1;i<=n;i++)
		printf("%I64d ",ans[i]);
	printf("\n");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=200100;
int a[N],n;
ll ans[N];
int main(){
	int i,j,k,fl=0,pos;
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<n;i++)
		if(a[i]!=a[i+1])
			fl=1;
	if(!fl){
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	pos=1;
	for(i=2;i<=n;i++)
		if(a[i]>a[pos])
			pos=i;
	if((pos==1)&&(a[n]==a[1]))
		for(pos=n;a[pos]==a[pos-1];pos--);
	ans[pos]=a[pos];
	for(i=pos-1;i;i--)
		ans[i]=ans[i+1]+a[i];
	if(pos!=n)
		ans[n]=ans[1]+a[n];
	for(i=n-1;i>pos;i--)
		ans[i]=ans[i+1]+a[i];
	for(i=1;i<=n;i++)
		printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=200100;
int a[N],n;
ll ans[N];
int main(){
	int i,j,k,fl=0,pos;
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<n;i++)
		if(a[i]!=a[i+1]){
			fl=2;
			break;
		}
		else if(a[i])
			fl=1;
	if(!fl){
		printf("YES\n");
		for(i=1;i<=n;i++)
			printf("1 ");
		printf("\n");
		return 0;
	}
	else if(fl==1){
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	pos=1;
	for(i=2;i<=n;i++)
		if(a[i]>a[pos])
			pos=i;
	if((pos==1)&&(a[n]==a[1]))
		for(pos=n;a[pos]==a[pos-1];pos--);
	ans[pos]=2*a[pos];
	for(i=pos-1;i;i--)
		ans[i]=ans[i+1]+a[i];
	if(pos!=n)
		ans[n]=ans[1]+a[n];
	for(i=n-1;i>pos;i--)
		ans[i]=ans[i+1]+a[i];
	ans[pos]=a[pos];
	for(i=1;i<=n;i++)
		printf("%I64d ",ans[i]);
	printf("\n");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=200100;
int a[N],n;
ll ans[N];
int main(){
	int i,j,k,fl=0,pos;
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<n;i++)
		if(a[i]!=a[i+1]){
			fl=2;
			break;
		}
		else if(a[i])
			fl=1;
	if(!fl){
		printf("YES\n");
		for(i=1;i<=n;i++)
			printf("1 ");
		printf("\n");
		return 0;
	}
	else if(fl==1){
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	pos=1;
	for(i=2;i<=n;i++)
		if(a[i]>a[pos])
			pos=i;
	if((pos==1)&&(a[n]==a[1]))
		for(pos=n;a[pos]==a[pos-1];pos--);
	ans[pos]=a[pos];
	for(i=pos-1;i;i--)
		ans[i]=ans[i+1]+a[i];
	if(pos!=n)
		ans[n]=ans[1]+a[n];
	for(i=n-1;i>pos;i--)
		ans[i]=ans[i+1]+a[i];
	for(i=1;i<=n;i++)
		printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


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

int n;
int A[200200];
long long B[200200];
int main(){
	scanf("%d",&n);
	int ind=0;
	bool found=false;
	for(int i=0;i<n;i++){
		scanf("%d",A+i);
		if(A[i] > A[ind]){
			ind = i;
		}
	}
	for(int i=0;i<n;i++){
		if(A[i] != A[ind]){
			found =true;
		}
	}
	if(!found){
		printf("NO\n");
		return 0;
	}
	for(int i=0;i<n;i++){
		int j= (n-1+i) % n;
		if(A[i]  == A[ind] && A[j] != A[ind]){
			ind = i;
			break;
		}
	}
	long long sm=0;
	for(int i=0;i<n;i++){
		int j= (ind + n - i) % n;
		if(A[j] == 0 && sm == A[ind]){
			sm *= 2;
		}
		sm += A[j];
		B[j] = sm;
	}
	printf("YES\n");
	for(int i=0;i<n;i++){
		printf("%lld ", B[i]);
	}/*
	for(int i=0;i<n;i++){
		if(A[i] != B[i] % B[(i+1)%n]){
			cout<<"ERRRRR"<<endl;
		}
	}
	while(1);*/
}


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

int n;
int A[200200];
long long B[200200];
int main(){
	scanf("%d",&n);
	int ind=0;
	bool found=false;
	for(int i=0;i<n;i++){
		scanf("%d",A+i);
		if(A[i] > A[ind]){
			ind = i;
		}
	}
	if(A[ind ] == 0){
		printf("YES\n");
		for(int i=0;i<n;i++){
			printf("%lld ", 5ll);
		}
		return 0;
	}
	for(int i=0;i<n;i++){
		if(A[i] != A[ind]){
			found =true;
		}
	}
	if(!found){
		printf("NO\n");
		return 0;
	}
	for(int i=0;i<n;i++){
		int j= (n-1+i) % n;
		if(A[i]  == A[ind] && A[j] != A[ind]){
			ind = i;
			break;
		}
	}
	long long sm=0;
	for(int i=0;i<n;i++){
		int j= (ind + n - i) % n;
		if(A[j] == 0 && sm == A[ind]){
			sm *= 2;
		}
		sm += A[j];
		B[j] = sm;
	}
	printf("YES\n");
	for(int i=0;i<n;i++){
		printf("%lld ", B[i]);
	}/*
	for(int i=0;i<n;i++){
		if(A[i] != B[i] % B[(i+1)%n]){
			cout<<"ERRRRR"<<endl;
		}
	}
	while(1);*/
}


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

int n;
int A[200200];
long long B[200200];
int main(){
	scanf("%d",&n);
	int ind=0;
	bool found=false;
	for(int i=0;i<n;i++){
		scanf("%d",A+i);
		if(A[i] > A[ind]){
			ind = i;
		}
	}
	for(int i=0;i<n;i++){
		if(A[i] != A[ind] && A[i] != 0){
			found =true;
		}
	}
	if(!found){
		printf("NO\n");
		return 0;
	}
	int inddd = ind;
	for(int i=0;i<n-1;i++){
		int j= (inddd -i - 1 + n)% n;
		if(A[j] == A[ind] ){
			ind =j;
		}
		if(A[j] != 0 && A[j] != A[ind]){
			break;
		}
	}
	long long sm=0;
	for(int i=0;i<n;i++){
		int j= (ind + n - i) % n;
		sm += A[j];
		B[j] = sm;
	}
	printf("YES\n");
	for(int i=0;i<n;i++){
		printf("%lld ", B[i]);
	}
	/*
	for(int i=0;i<n;i++){
		if(A[i] != B[i] % B[(i+1)%n]){
			cout<<"ERRRRR"<<endl;
		}
	}
	while(1);*/
}


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

int n;
int A[200200];
long long B[200200];
int main(){
	scanf("%d",&n);
	int ind=0;
	bool found=false;
	for(int i=0;i<n;i++){
		scanf("%d",A+i);
		if(A[i] > A[ind]){
			ind = i;
		}
	}
	if(A[ind ] == 0){
		printf("YES\n");
		for(int i=0;i<n;i++){
			printf("%lld ", 5);
		}
		return 0;
	}
	for(int i=0;i<n;i++){
		if(A[i] != A[ind]){
			found =true;
		}
	}
	if(!found){
		printf("NO\n");
		return 0;
	}
	for(int i=0;i<n;i++){
		int j= (n-1+i) % n;
		if(A[i]  == A[ind] && A[j] != A[ind]){
			ind = i;
			break;
		}
	}
	long long sm=0;
	for(int i=0;i<n;i++){
		int j= (ind + n - i) % n;
		if(A[j] == 0 && sm == A[ind]){
			sm *= 2;
		}
		sm += A[j];
		B[j] = sm;
	}
	printf("YES\n");
	for(int i=0;i<n;i++){
		printf("%lld ", B[i]);
	}/*
	for(int i=0;i<n;i++){
		if(A[i] != B[i] % B[(i+1)%n]){
			cout<<"ERRRRR"<<endl;
		}
	}
	while(1);*/
}


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

int n;
int A[200200];
long long B[200200];
int main(){
	scanf("%d",&n);
	int ind=0;
	bool found=false;
	for(int i=0;i<n;i++){
		scanf("%d",A+i);
		if(A[i] > A[ind]){
			ind = i;
		}
		if (i > 0 && A[i] != A[i-1]){
			found=true;
		}
	}
	if(!found){
		printf("NO\n");
		return 0;
	}
	for(int i=0;i<n;i++){
		int j = (i+n-1) % n;
		if(A[j] < A[ind] && A[i] == A[ind]){
			ind = i;
			break;
		}
	}
	long long sm=0;
	for(int i=0;i<n;i++){
		int j= (ind + n - i) % n;
		sm += A[j];
		B[j] = sm;
	}
	printf("YES\n");
	for(int i=0;i<n;i++){
		printf("%lld ", B[i]);
	}
}


#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=2e5 +10 ;

LL a[N], b[N];
int n;
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	int ii=1;
	cin>>n;
	bool flag =true;
	for (int i=0; i<n; ++i) cin>>b[i];
	for (int i=0; i<n; ++i){

		if ( b[i] > b[ii] && b[i] != b[(i-1+n)%n] )  ii=i;
		if ( i && b[i] != b[i-1] ) flag= false;
	}
	if ( flag){
		if ( b[0] ) puts("NO");
			else{
				puts("YES");
				for (int i=0; i<n; ++i) printf("1 ");
			}
		return 0;
	}
	a[ii] = b[ii];
	LL pre= 2*b[ii];
	for (int i=1; i<n; ++i){
		int j = (ii-i+n)%n;
		pre += b[j];
		a[j]  =pre;
	}
	puts("YES");
	for (int i=0; i<n; ++i) printf("%lld ", a[i]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=2e5 +10 ;

LL a[N], b[N];
int n;
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	int ii=1;
	cin>>n;
	bool flag =true;
	for (int i=0; i<n; ++i){
		cin>>b[i];
		if ( b[i] > b[ii] && b[i] != b[(i-1+n)%n] )  ii=i;
		if ( i && b[i] != b[i-1] ) flag= false;
	}
	if ( flag){
		if ( b[0] ) puts("NO");
			else{
				puts("YES");
				for (int i=0; i<n; ++i) printf("1 ");
			}
		return 0;
	}
	a[ii] = b[ii];
	LL pre= 2*b[ii];
	for (int i=1; i<n; ++i){
		int j = (ii-i+n)%n;
		pre += b[j];
		a[j]  =pre;
	}
	puts("YES");
	for (int i=0; i<n; ++i) printf("%lld ", a[i]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=2e5 +10 ;

LL a[N], b[N];
int n;
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	int ii=1;
	cin>>n;
	bool flag =true;
	for (int i=0; i<n; ++i){
		cin>>b[i];
		if ( b[i] > b[ii] )  ii=i;
		if ( i && b[i] != b[i-1] ) flag= false;
	}
	if ( flag){
		if ( b[0] ) puts("NO");
			else{
				puts("YES");
				for (int i=0; i<n; ++i) printf("1 ");
			}
		return 0;
	}
	a[ii] = b[ii];
	LL pre= 2*b[ii];
	for (int i=1; i<n; ++i){
		int j = (ii-i+n)%n;
		pre += b[j];
		a[j]  =pre;
	}
	puts("YES");
	for (int i=0; i<n; ++i) printf("%lld ", a[i]);
	return 0;
}


import java.io.*;
import java.util.*;

public class A {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int tst = Integer.parseInt(br.readLine());
        while(tst-->0){
            String[] str = br.readLine().split(" ");
            int n = Integer.parseInt(str[0]), k = Integer.parseInt(str[1]);
            StringTokenizer st = new StringTokenizer(br.readLine());
            Integer[] arr = new Integer[n];
            for(int i = 0; i<n; i++){
                arr[i] = Integer.parseInt(st.nextToken());
            }
            Arrays.sort(arr);
            int ans = 0;
            for(int i = 1; i<n; i++){
                ans += (k-arr[i])/arr[0];
            }
            sb.append(ans).append('\n');
        }
        System.out.println(sb);
    }
}


import java.util.*;
 public class Main
{
 public static void main(String [] args)
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int ii=0;ii<t;ii++)
{
int n=sc.nextInt();
int k=sc.nextInt();

long ar[]=new long[n];
long max=-1;
for(int i=0;i<n;i++)
{long f=sc.nextLong();
    ar[i]=f;
    }long count=0;
    Arrays.sort(ar);
    for(int i=1;i<n;i++)
    {
        if(ar[i]<=k)
        count+=(k-ar[i])/ar[0];
    }
    System.out.println(count);}}}