stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <stdio.h>

#include <string.h>

#include <vector>

#include <string>

#include <cmath>

#include <ctime>

#include <queue>

#include <stack>

#include <set>

#include <iostream>

#include <map>

#include <algorithm>

const double PI = acos(-1.0);

const double EPS = 1e-9;

using namespace std;



const int maxn = 1e5 + 5;

const int INF = 0x3f3f3f3f;

#define LL long long



LL a[maxn], b[maxn];



int main()

{

	LL n;

	while (scanf("%lld", &n) != EOF)

	{

		LL sum = 0;

		for (int i = 0; i < n; i++)

		{

			scanf("%lld", &a[i]);

			sum += a[i];

		}

		for (int i = 0; i < n - 1; i++) b[i] = a[i + 1] - a[i];

		b[n - 1] = a[0] - a[n - 1];

		LL t = n*(n + 1) / 2;

		if (sum%t)

		{

			puts("NO");

			continue;

		}

		sum /= t;

		LL cnt = 0;

		bool ok = true;

		for (int i = 0; i < n; i++)

		{

			if ( (sum - b[i]) % n || sum - b[i] < 0)

			{

				ok = false;

				break;

			}

			cnt += (sum - b[i]) / n;

		}

		if (!ok)

		{

			puts("NO");

			continue;

		}

		if (cnt == sum)

			puts("YES");

		else

			puts("NO");

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.238980872671765x):
#include<stdio.h>

int main(){

    long long n,i,a,b,c,d,max,s=0,s1,m,p=1;

    scanf("%lld",&n);

    if(n==1){

        printf("YES\n");

        return 0;

    }

    scanf("%lld%lld",&a,&b);

    s+=a+b;

    d=(b-a)%n;

    max=b-a;

    for(i=2;i<n;i++){

        scanf("%lld",&c);

        if((c-b-d)%n!=0){

            p=0;

            break;

        }

        if(c-b>max) max=c-b;

        s+=c;

        b=c;

    }

    if((a-b-d)%n!=0) p=0;

    if(a-b>max) max=a-b;

    if(p){

        s1=n*(n+1)/2;

        if(s%s1!=0){

            p=0;

        }else{

            m=s/s1;

            if((m-d)%n!=0 || max>m) p=0;

        }

    }

    if(p) printf("YES\n"); else printf("NO\n");

}
// Slower C++ solution:
#include <vector>

#include <list>

#include <map>

#include <set>

#include "queue"

#include <deque>

#include <stack>

#include <numeric>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <complex>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstring>

#include <climits>

#include <cassert>

#include <iostream>

#include "fstream"

using namespace std;

#define PI acos(-1)

#define MOD (ll)1000000007

#define pii pair<long long ,long long >

#define ll  long long int

#define loop(i,n) for(ll i=0;i<n;i++)

#define loop2(i,n) for(ll i = 1;i<=n;i+=1)

#define pb push_back

#define mp make_pair

#define EPS 1e-8

void display(vector<ll> v1){loop(i,v1.size()){cout<<v1[i]<<" ";}cout<<endl;}

ll dx[8] = {0,1,0,-1,1,1,-1,-1};

ll dy[8] = {1,0,-1,0,1,-1,1,-1};



//Jai Shree Krishna

//:) :) :( :( :( :( :( :( :) :( :)

//Purple Dreams ??? 

//Shit ;More Shit and Hell lot of Shit and Still Shit 



const int MAXN = (ll)1e5+1000;

ll A[MAXN];

ll B[MAXN];



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    ll n;

    cin>>n;

    ll sum = 0 ;

    loop(i,n)

    {

        cin>>A[i];

        sum+=A[i];

    }

    ll t  = (n*(n+1))/2;

    

    if(sum%t)

    {

        cout<<"NO"<<endl;

        return 0;

    }

    ll cnt = sum/t;

    loop(i,n)

    {

        B[i] = A[(i+1)%n]-A[i]-cnt;

    }

    bool flag = true;

    loop(i,n)

    {

        if(B[i]>0||(-B[i])%n)

        {

            flag = false;

        }

    }

    if(flag)

    {

        cout<<"YES";

    }

    else{

        cout<<"NO";

    }

    cout<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.382156060232937x):
#include<stdio.h>

int main(){

    long long n,i,a,b,c,d,max,s=0,s1,m,p=1;

    scanf("%lld",&n);

    if(n==1){

        printf("YES\n");

        return 0;

    }

    scanf("%lld%lld",&a,&b);

    s+=a+b;

    d=(b-a)%n;

    max=b-a;

    for(i=2;i<n;i++){

        scanf("%lld",&c);

        if((c-b-d)%n!=0){

            p=0;

            break;

        }

        if(c-b>max) max=c-b;

        s+=c;

        b=c;

    }

    if((a-b-d)%n!=0) p=0;

    if(a-b>max) max=a-b;

    if(p){

        s1=n*(n+1)/2;

        if(s%s1!=0){

            p=0;

        }else{

            m=s/s1;

            if((m-d)%n!=0 || max>m) p=0;

        }

    }

    if(p) printf("YES\n"); else printf("NO\n");

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

typedef long long ll;

ll a[100005],dis[100005];

int main(){

	ll n,i;

	scanf("%lld",&n);

	ll sum=0;

	for(i=1;i<=n;i++)scanf("%lld",&a[i]),sum+=a[i];

	if(sum%(n*(n+1)/2)){

		printf("NO\n");

		return 0;

	}

	sum/=(n*(n+1))/2;

	dis[1]=a[1]-a[n];

	for(i=2;i<=n;i++)dis[i]=a[i]-a[i-1];

	ll cnt=0;

	for(i=1;i<=n;i++){

		if((sum-dis[i]<0)||(sum-dis[i])%n){

			printf("NO\n"); 

			return 0;

		}

		else cnt+=(sum-dis[i])/n;

	}

	if(cnt!=sum)printf("NO\n");

	else printf("YES\n");

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.283541315354951x):
#include<stdio.h>

int main(){

    long long n,i,a,b,c,d,max,s=0,s1,m,p=1;

    scanf("%lld",&n);

    if(n==1){

        printf("YES\n");

        return 0;

    }

    scanf("%lld%lld",&a,&b);

    s+=a+b;

    d=(b-a)%n;

    max=b-a;

    for(i=2;i<n;i++){

        scanf("%lld",&c);

        if((c-b-d)%n!=0){

            p=0;

            break;

        }

        if(c-b>max) max=c-b;

        s+=c;

        b=c;

    }

    if((a-b-d)%n!=0) p=0;

    if(a-b>max) max=a-b;

    if(p){

        s1=n*(n+1)/2;

        if(s%s1!=0){

            p=0;

        }else{

            m=s/s1;

            if((m-d)%n!=0 || max>m) p=0;

        }

    }

    if(p) printf("YES\n"); else printf("NO\n");

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

int main()

{

	long long n,a[100005],dis[100005];

	long long sum=0;

	scanf("%lld",&n);

	for(int i=1;i<=n;i++)

	{

		scanf("%lld",&a[i]);

		sum+=a[i];

	}

	if(sum%(n*(n+1)/2))

	printf("NO\n");

	else

	{

		long long k=sum/((n*(n+1))/2);

		dis[1]=a[1]-a[n];

	    for(int i=2;i<=n;i++)

	    dis[i]=a[i]-a[i-1];

	    int flag=1;

	    long long cnt=0;

	    for(int i=1;i<=n;i++)

	    {

	    	if(k-dis[i]<0||(k-dis[i])%n)

	    	flag=0;

	    	else

	    	cnt+=(k-dis[i])/n;

		}

		if(cnt!=k)

		flag=0;

		if(flag)

		printf("YES\n");

		else

		printf("NO\n");

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.444709764342797x):
#include<stdio.h>

int main(){

    long long n,i,a,b,c,d,max,s=0,s1,m,p=1;

    scanf("%lld",&n);

    if(n==1){

        printf("YES\n");

        return 0;

    }

    scanf("%lld%lld",&a,&b);

    s+=a+b;

    d=(b-a)%n;

    max=b-a;

    for(i=2;i<n;i++){

        scanf("%lld",&c);

        if((c-b-d)%n!=0){

            p=0;

            break;

        }

        if(c-b>max) max=c-b;

        s+=c;

        b=c;

    }

    if((a-b-d)%n!=0) p=0;

    if(a-b>max) max=a-b;

    if(p){

        s1=n*(n+1)/2;

        if(s%s1!=0){

            p=0;

        }else{

            m=s/s1;

            if((m-d)%n!=0 || max>m) p=0;

        }

    }

    if(p) printf("YES\n"); else printf("NO\n");

}
// Slower C++ solution:
#include<stdio.h>

#include<cstring>

int main()

{

    long long n,a,judge,sum,k;

    long long s1[100010],dis[100010];

    while(scanf("%lld",&n)!=EOF)

    {

        sum=0;

        for(a=1; a<=n; a++)

        {

            scanf("%lld",&s1[a]);

            sum+=s1[a];

        }

        dis[1]=s1[1]-s1[n];

        for(a=2; a<=n; a++)

        {

            dis[a]=s1[a]-s1[a-1];

        }

        if(sum%((1+n)*n/2))

        {

            printf("NO\n");

        }

        else

        {

            judge=0;

            k=sum/((1+n)*n/2);

            sum=0;

            for(a=1; a<=n; a++)

            {

                if((k-dis[a])%n||k<dis[a])

                  {

                    judge=1;

                  }

                else

                    sum+=(k-dis[a])/n;

            }

            if(sum!=k)printf("NO\n");

            else

            {

                if(judge)printf("NO\n");

                else printf("YES\n");

            }

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.2069275445222527x):
#include<stdio.h>

int main(){

    long long n,i,a,b,c,d,max,s=0,s1,m,p=1;

    scanf("%lld",&n);

    if(n==1){

        printf("YES\n");

        return 0;

    }

    scanf("%lld%lld",&a,&b);

    s+=a+b;

    d=(b-a)%n;

    max=b-a;

    for(i=2;i<n;i++){

        scanf("%lld",&c);

        if((c-b-d)%n!=0){

            p=0;

            break;

        }

        if(c-b>max) max=c-b;

        s+=c;

        b=c;

    }

    if((a-b-d)%n!=0) p=0;

    if(a-b>max) max=a-b;

    if(p){

        s1=n*(n+1)/2;

        if(s%s1!=0){

            p=0;

        }else{

            m=s/s1;

            if((m-d)%n!=0 || max>m) p=0;

        }

    }

    if(p) printf("YES\n"); else printf("NO\n");

}
// Slower C++ solution:
#include <cstdio>  

#include <cmath>  

#include <iostream>  

#include <algorithm>  

#include <cstring>  

#include <cctype>  

#include <stack>  

using namespace std;  

  

typedef long long ll;  

const int qq = 1e5 + 10;  

ll diff[qq];  

ll num[qq];  

ll n;  

  

int main(){  

    scanf("%lld", &n);  

    ll sum = 0;  

    for(int i = 0; i < n; ++i)   scanf("%lld", num + i), sum += num[i];  

    for(int i = 0; i < n - 1; ++i)  

        diff[i] = num[i + 1] - num[i];  

    diff[n - 1] = num[0] - num[n - 1];  

    ll k = (1 + n) * n / 2;  

    if(sum % k != 0){  

        printf("NO\n");  

        return 0;  

    }  

    k = sum / k;  

    for(int i = 0; i < n; ++i){  

        if(k == diff[i])    continue;  

        ll c = k - diff[i];  

        if(c < 0 || c % n != 0){  

            printf("NO\n");  

            return 0;  

        }  

    }  

    printf("YES\n");  

    return 0;  

}  




// Faster C++ solution for the same problem (measured speedup: 5.240963883597705x):
#include<stdio.h>

int main(){

    long long n,i,a,b,c,d,max,s=0,s1,m,p=1;

    scanf("%lld",&n);

    if(n==1){

        printf("YES\n");

        return 0;

    }

    scanf("%lld%lld",&a,&b);

    s+=a+b;

    d=(b-a)%n;

    max=b-a;

    for(i=2;i<n;i++){

        scanf("%lld",&c);

        if((c-b-d)%n!=0){

            p=0;

            break;

        }

        if(c-b>max) max=c-b;

        s+=c;

        b=c;

    }

    if((a-b-d)%n!=0) p=0;

    if(a-b>max) max=a-b;

    if(p){

        s1=n*(n+1)/2;

        if(s%s1!=0){

            p=0;

        }else{

            m=s/s1;

            if((m-d)%n!=0 || max>m) p=0;

        }

    }

    if(p) printf("YES\n"); else printf("NO\n");

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define int long long

#define F first

#define ll long long 

#define S second

#define pb push_back

const int inf = 1000 * 1000 * 1000 + 1000;

const ll INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;



const int N = 1000 * 100 + 1000;

int a[N], d[N], x[N];



int32_t main(){

	ios::sync_with_stdio(false);cin.tie(0);



	int n, k, sum = 0, step;

	cin >> n;

	step = n * (n + 1) / 2;

	for(int i = 0; i < n; i++)

		cin >> a[i], sum += a[i];



	if(sum % step != 0){

		cout << "NO\n";

		return 0;

	}



	k = sum / step;

	for(int i = 0; i < n - 1; i++)

		d[i] = a[i + 1] - a[i];

	d[n - 1] = a[0] - a[n - 1];



	sum = 0;

	for(int i = 0; i < n; i++){

		int cnt = k - d[i];

		if(cnt % n != 0 || cnt < 0){

			cout << "NO\n";

			return 0;

		}

		x[i] = cnt / n;

		sum += x[i];

	}

	if(sum != k)

		cout << "NO\n";

	else

		cout << "YES\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.3750530680297315x):
#include<stdio.h>

int main(){

    long long n,i,a,b,c,d,max,s=0,s1,m,p=1;

    scanf("%lld",&n);

    if(n==1){

        printf("YES\n");

        return 0;

    }

    scanf("%lld%lld",&a,&b);

    s+=a+b;

    d=(b-a)%n;

    max=b-a;

    for(i=2;i<n;i++){

        scanf("%lld",&c);

        if((c-b-d)%n!=0){

            p=0;

            break;

        }

        if(c-b>max) max=c-b;

        s+=c;

        b=c;

    }

    if((a-b-d)%n!=0) p=0;

    if(a-b>max) max=a-b;

    if(p){

        s1=n*(n+1)/2;

        if(s%s1!=0){

            p=0;

        }else{

            m=s/s1;

            if((m-d)%n!=0 || max>m) p=0;

        }

    }

    if(p) printf("YES\n"); else printf("NO\n");

}
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <cstdio>

#include <fstream>

#include <map>

#include <vector>

//#include <unordered_map>

//#include <unordered_set>

#include <stack>

#include <set>

#include <queue>

#include <list>



using namespace std;

int k[100005];

int main()

{

    int n;

    long long su=0,z;

    scanf("%d",&n);

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

    z=((long long)n+1)*n/2;

    if(su%z==0)

    {

        long long f=su/z;

        long long co=f;

        for(int i=1;i<n;++i)

        {

            if(k[i]-k[i-1]>f)

            {

                printf("NO");

                return 0;

            }

            else

            {

                long long tm=f-k[i]+k[i-1];

                if(tm%n==0)

                {

                    co-=tm/n;

                }

            }

        }

        if(k[0]-k[n-1]>f)

        {

            printf("NO");

            return 0;

        }

        else

        {

            long long tm=f-k[0]+k[n-1];

                if(tm%n==0)

                {

                    co-=tm/n;

                }

        }

        if(co==0) printf("YES");

        else printf("NO");

    }

    else

    {

        printf("NO");

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.284512747753119x):
#include<stdio.h>

int main(){

    long long n,i,a,b,c,d,max,s=0,s1,m,p=1;

    scanf("%lld",&n);

    if(n==1){

        printf("YES\n");

        return 0;

    }

    scanf("%lld%lld",&a,&b);

    s+=a+b;

    d=(b-a)%n;

    max=b-a;

    for(i=2;i<n;i++){

        scanf("%lld",&c);

        if((c-b-d)%n!=0){

            p=0;

            break;

        }

        if(c-b>max) max=c-b;

        s+=c;

        b=c;

    }

    if((a-b-d)%n!=0) p=0;

    if(a-b>max) max=a-b;

    if(p){

        s1=n*(n+1)/2;

        if(s%s1!=0){

            p=0;

        }else{

            m=s/s1;

            if((m-d)%n!=0 || max>m) p=0;

        }

    }

    if(p) printf("YES\n"); else printf("NO\n");

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

const int maxn=1e5+10;

int n,a[maxn];

bool check()

{

	LL s=0;

	for (int i=1;i<=n;i++) s+=a[i];

	s*=2;

	if (s%((LL)n*(n+1))!=0) return 0;

	s/=n;s/=(n+1);

	for (int i=1;i<n;i++)

	{

		LL s1=a[i]-a[i+1]+s;

		if (s1<0||s1%n!=0) return 0;

	}

	LL s1=a[n]-a[1]+s;

	if (s1<0||s1%n!=0) return 0;

	return 1;

}

int main()

{

	cin>>n;

	for (int i=1;i<=n;i++) scanf("%I64d",&a[i]);

	if (check()) printf("YES");

	else printf("NO");

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.307463102782528x):
#include <cstdio>

int a[100005];

int main(int argc, char const *argv[])

{

    long long n;

    long long suma =0;

    scanf("%lld",&n);

    for(int i=0;i<n;i++){

        scanf("%d",&a[i]);

        suma += a[i];

    }

    long long sumy = suma/(((1+n)*n)/2);

    if(sumy * (((1+n)*n)/2) != suma ){

        printf("NO\n");

        return 0;

    }





    for (int i=0;i<n-1;i++){

        long long k = a[i+1]-a[i];

        long long y = (sumy - k)/n;

        if(y<0 || y*n != sumy -k){

            printf("NO\n");

            return 0;

        }



    }

    printf("YES\n");





    return 0;

}
// Slower C++ solution:
#include <map>

#include <set>

#include <cmath>

#include <ctime>

#include <stack>

#include <queue>

#include <cstdio>

#include <cctype>

#include <bitset>

#include <string>

#include <vector>

#include <climits>

#include <cstring>

#include <iostream>

#include <iomanip>

#include <algorithm>

#include <functional>

#define fuck(x) cout<<"["<<x<<"]";

#define FIN freopen("input.txt","r",stdin);

#define FOUT freopen("output.txt","w+",stdout);

using namespace std;

typedef long long LL;

typedef pair<int, int> PII;



const int MX = 1e5 + 5;

const int INF = 0x3f3f3f3f;

const int mod = 1e9 + 7;



int n;

LL A[MX], B[MX], sum;



bool solve() {

    LL tot = (LL)(1 + n) * n / 2;

    if(sum % tot != 0) return 0;



    LL k = sum / tot, used = 0;

    for(int i = 1; i <= n; i++) {

        int last = i == 1 ? n : i - 1;

        B[i] = A[i] - A[last];



        if((k - B[i]) % n != 0 || (k - B[i]) < 0) {

            return 0;

        }

        used += (k - B[i]) / n;

    }

    return used == k;

}



int main() {

    // FIN;

    scanf("%d", &n);

    for(int i = 1; i <= n; i++) {

        scanf("%lld", &A[i]);

        sum += A[i];

    }

    printf("%s\n", solve() ? "YES" : "NO");

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.237606013390007x):
#include <cstdio>

int a[100005];

int main(int argc, char const *argv[])

{

    long long n;

    long long suma =0;

    scanf("%lld",&n);

    for(int i=0;i<n;i++){

        scanf("%d",&a[i]);

        suma += a[i];

    }

    long long sumy = suma/(((1+n)*n)/2);

    if(sumy * (((1+n)*n)/2) != suma ){

        printf("NO\n");

        return 0;

    }





    for (int i=0;i<n-1;i++){

        long long k = a[i+1]-a[i];

        long long y = (sumy - k)/n;

        if(y<0 || y*n != sumy -k){

            printf("NO\n");

            return 0;

        }



    }

    printf("YES\n");





    return 0;

}
// Slower C++ solution:
#include <stdio.h>

#include <string.h>

#include <vector>

#include <string>

#include <cmath>

#include <ctime>

#include <queue>

#include <stack>

#include <set>

#include <iostream>

#include <map>

#include <algorithm>

const double PI = acos(-1.0);

const double EPS = 1e-9;

using namespace std;



const int maxn = 1e5 + 5;

const int INF = 0x3f3f3f3f;

#define LL long long



LL a[maxn], b[maxn];



int main()

{

	LL n;

	while (scanf("%lld", &n) != EOF)

	{

		LL sum = 0;

		for (int i = 0; i < n; i++)

		{

			scanf("%lld", &a[i]);

			sum += a[i];

		}

		for (int i = 0; i < n - 1; i++) b[i] = a[i + 1] - a[i];

		b[n - 1] = a[0] - a[n - 1];

		LL t = n*(n + 1) / 2;

		if (sum%t)

		{

			puts("NO");

			continue;

		}

		sum /= t;

		LL cnt = 0;

		bool ok = true;

		for (int i = 0; i < n; i++)

		{

			if ( (sum - b[i]) % n || sum - b[i] < 0)

			{

				ok = false;

				break;

			}

			cnt += (sum - b[i]) / n;

		}

		if (!ok)

		{

			puts("NO");

			continue;

		}

		if (cnt == sum)

			puts("YES");

		else

			puts("NO");

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.225312313826803x):
#include <cstdio>

int a[100005];

int main(int argc, char const *argv[])

{

    long long n;

    long long suma =0;

    scanf("%lld",&n);

    for(int i=0;i<n;i++){

        scanf("%d",&a[i]);

        suma += a[i];

    }

    long long sumy = suma/(((1+n)*n)/2);

    if(sumy * (((1+n)*n)/2) != suma ){

        printf("NO\n");

        return 0;

    }





    for (int i=0;i<n-1;i++){

        long long k = a[i+1]-a[i];

        long long y = (sumy - k)/n;

        if(y<0 || y*n != sumy -k){

            printf("NO\n");

            return 0;

        }



    }

    printf("YES\n");





    return 0;

}
// Slower C++ solution:
#include <vector>

#include <list>

#include <map>

#include <set>

#include "queue"

#include <deque>

#include <stack>

#include <numeric>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <complex>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstring>

#include <climits>

#include <cassert>

#include <iostream>

#include "fstream"

using namespace std;

#define PI acos(-1)

#define MOD (ll)1000000007

#define pii pair<long long ,long long >

#define ll  long long int

#define loop(i,n) for(ll i=0;i<n;i++)

#define loop2(i,n) for(ll i = 1;i<=n;i+=1)

#define pb push_back

#define mp make_pair

#define EPS 1e-8

void display(vector<ll> v1){loop(i,v1.size()){cout<<v1[i]<<" ";}cout<<endl;}

ll dx[8] = {0,1,0,-1,1,1,-1,-1};

ll dy[8] = {1,0,-1,0,1,-1,1,-1};



//Jai Shree Krishna

//:) :) :( :( :( :( :( :( :) :( :)

//Purple Dreams ??? 

//Shit ;More Shit and Hell lot of Shit and Still Shit 



const int MAXN = (ll)1e5+1000;

ll A[MAXN];

ll B[MAXN];



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    ll n;

    cin>>n;

    ll sum = 0 ;

    loop(i,n)

    {

        cin>>A[i];

        sum+=A[i];

    }

    ll t  = (n*(n+1))/2;

    

    if(sum%t)

    {

        cout<<"NO"<<endl;

        return 0;

    }

    ll cnt = sum/t;

    loop(i,n)

    {

        B[i] = A[(i+1)%n]-A[i]-cnt;

    }

    bool flag = true;

    loop(i,n)

    {

        if(B[i]>0||(-B[i])%n)

        {

            flag = false;

        }

    }

    if(flag)

    {

        cout<<"YES";

    }

    else{

        cout<<"NO";

    }

    cout<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.36811395574544x):
#include <cstdio>

int a[100005];

int main(int argc, char const *argv[])

{

    long long n;

    long long suma =0;

    scanf("%lld",&n);

    for(int i=0;i<n;i++){

        scanf("%d",&a[i]);

        suma += a[i];

    }

    long long sumy = suma/(((1+n)*n)/2);

    if(sumy * (((1+n)*n)/2) != suma ){

        printf("NO\n");

        return 0;

    }





    for (int i=0;i<n-1;i++){

        long long k = a[i+1]-a[i];

        long long y = (sumy - k)/n;

        if(y<0 || y*n != sumy -k){

            printf("NO\n");

            return 0;

        }



    }

    printf("YES\n");





    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

typedef long long ll;

ll a[100005],dis[100005];

int main(){

	ll n,i;

	scanf("%lld",&n);

	ll sum=0;

	for(i=1;i<=n;i++)scanf("%lld",&a[i]),sum+=a[i];

	if(sum%(n*(n+1)/2)){

		printf("NO\n");

		return 0;

	}

	sum/=(n*(n+1))/2;

	dis[1]=a[1]-a[n];

	for(i=2;i<=n;i++)dis[i]=a[i]-a[i-1];

	ll cnt=0;

	for(i=1;i<=n;i++){

		if((sum-dis[i]<0)||(sum-dis[i])%n){

			printf("NO\n"); 

			return 0;

		}

		else cnt+=(sum-dis[i])/n;

	}

	if(cnt!=sum)printf("NO\n");

	else printf("YES\n");

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.269756497823849x):
#include <cstdio>

int a[100005];

int main(int argc, char const *argv[])

{

    long long n;

    long long suma =0;

    scanf("%lld",&n);

    for(int i=0;i<n;i++){

        scanf("%d",&a[i]);

        suma += a[i];

    }

    long long sumy = suma/(((1+n)*n)/2);

    if(sumy * (((1+n)*n)/2) != suma ){

        printf("NO\n");

        return 0;

    }





    for (int i=0;i<n-1;i++){

        long long k = a[i+1]-a[i];

        long long y = (sumy - k)/n;

        if(y<0 || y*n != sumy -k){

            printf("NO\n");

            return 0;

        }



    }

    printf("YES\n");





    return 0;

}