stablegradients/pie-gem5-pairs huggingface dataset:
// 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: 4.459386219711638x):
#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;

}
// 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: 4.377678957891689x):
#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;

}
// 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: 4.511215100735826x):
#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;

}
// 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.183623460608023x):
#include<cstdio>



typedef long long ll;

const int N=100005;

ll sum=0,a[N],t=0;

int main()

{

    int n;

    scanf("%d",&n);

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

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

        sum+=a[i];

        t+=i;

    }

    if(sum%t)   printf("NO\n");

    else{

        ll tmp=a[1];

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

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

        a[n]=tmp-a[n];

        ll r=sum/t;

        bool flag=true;

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

            a[i]-=r;

            if(a[i]%n || a[i]>0){

                flag=false;

                break;

            }

        }

        if(flag)    printf("YES\n");

        else printf("NO\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.115396354653198x):
#include<cstdio>



typedef long long ll;

const int N=100005;

ll sum=0,a[N],t=0;

int main()

{

    int n;

    scanf("%d",&n);

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

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

        sum+=a[i];

        t+=i;

    }

    if(sum%t)   printf("NO\n");

    else{

        ll tmp=a[1];

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

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

        a[n]=tmp-a[n];

        ll r=sum/t;

        bool flag=true;

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

            a[i]-=r;

            if(a[i]%n || a[i]>0){

                flag=false;

                break;

            }

        }

        if(flag)    printf("YES\n");

        else printf("NO\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.1033895053846505x):
#include<cstdio>



typedef long long ll;

const int N=100005;

ll sum=0,a[N],t=0;

int main()

{

    int n;

    scanf("%d",&n);

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

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

        sum+=a[i];

        t+=i;

    }

    if(sum%t)   printf("NO\n");

    else{

        ll tmp=a[1];

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

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

        a[n]=tmp-a[n];

        ll r=sum/t;

        bool flag=true;

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

            a[i]-=r;

            if(a[i]%n || a[i]>0){

                flag=false;

                break;

            }

        }

        if(flag)    printf("YES\n");

        else printf("NO\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.242859140298309x):
#include<cstdio>



typedef long long ll;

const int N=100005;

ll sum=0,a[N],t=0;

int main()

{

    int n;

    scanf("%d",&n);

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

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

        sum+=a[i];

        t+=i;

    }

    if(sum%t)   printf("NO\n");

    else{

        ll tmp=a[1];

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

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

        a[n]=tmp-a[n];

        ll r=sum/t;

        bool flag=true;

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

            a[i]-=r;

            if(a[i]%n || a[i]>0){

                flag=false;

                break;

            }

        }

        if(flag)    printf("YES\n");

        else printf("NO\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.14679666816528x):
#include<cstdio>



typedef long long ll;

const int N=100005;

ll sum=0,a[N],t=0;

int main()

{

    int n;

    scanf("%d",&n);

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

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

        sum+=a[i];

        t+=i;

    }

    if(sum%t)   printf("NO\n");

    else{

        ll tmp=a[1];

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

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

        a[n]=tmp-a[n];

        ll r=sum/t;

        bool flag=true;

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

            a[i]-=r;

            if(a[i]%n || a[i]>0){

                flag=false;

                break;

            }

        }

        if(flag)    printf("YES\n");

        else printf("NO\n");

    }

    return 0;

}
// 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.303793876430374x):
#include<cstdio>



typedef long long ll;

const int N=100005;

ll sum=0,a[N],t=0;

int main()

{

    int n;

    scanf("%d",&n);

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

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

        sum+=a[i];

        t+=i;

    }

    if(sum%t)   printf("NO\n");

    else{

        ll tmp=a[1];

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

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

        a[n]=tmp-a[n];

        ll r=sum/t;

        bool flag=true;

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

            a[i]-=r;

            if(a[i]%n || a[i]>0){

                flag=false;

                break;

            }

        }

        if(flag)    printf("YES\n");

        else printf("NO\n");

    }

    return 0;

}
// 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.1756907524904479x):
#include<cstdio>



typedef long long ll;

const int N=100005;

ll sum=0,a[N],t=0;

int main()

{

    int n;

    scanf("%d",&n);

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

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

        sum+=a[i];

        t+=i;

    }

    if(sum%t)   printf("NO\n");

    else{

        ll tmp=a[1];

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

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

        a[n]=tmp-a[n];

        ll r=sum/t;

        bool flag=true;

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

            a[i]-=r;

            if(a[i]%n || a[i]>0){

                flag=false;

                break;

            }

        }

        if(flag)    printf("YES\n");

        else printf("NO\n");

    }

    return 0;

}
// 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.105321193511496x):
#include<cstdio>



typedef long long ll;

const int N=100005;

ll sum=0,a[N],t=0;

int main()

{

    int n;

    scanf("%d",&n);

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

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

        sum+=a[i];

        t+=i;

    }

    if(sum%t)   printf("NO\n");

    else{

        ll tmp=a[1];

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

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

        a[n]=tmp-a[n];

        ll r=sum/t;

        bool flag=true;

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

            a[i]-=r;

            if(a[i]%n || a[i]>0){

                flag=false;

                break;

            }

        }

        if(flag)    printf("YES\n");

        else printf("NO\n");

    }

    return 0;

}
// 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.321346554599537x):
#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 <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.2513067305339955x):
#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");

}