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

#include <set>

#include <cmath>

#include <queue>

#include <stack>

#include <vector>

#include <cstdio>

#include <string>

#include <cstring>

#include <climits>

#include <cstdlib>

#include <iostream>

#include <algorithm>

using namespace std;

#define Mem(a) memset(a,0,sizeof(a))

#define mem(a) memset(a,-1,sizeof(a))

#define For(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);++(i))

#define FOR(i,l,r) for(int (i)=(int)(l);(i)<=(int)(r);++(i))

#define rof(i,l,r) for(int (i)=(int)(l);(i)>=(int)(r);--(i))

#define all(x) (x).begin(),(x).end()

#define mp make_pair

#define pb push_back

typedef pair<int,int> pii;

typedef vector<pii> vpii;

typedef vector<int> vi;

typedef unsigned long long llu;

typedef long long ll;

const int mxn=1e5+3;

const int inf=INT_MAX;

ll a[mxn],n;

int main(){

	scanf("%lld",&n);

	ll sum=0;

	For(i,0,n){

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

		sum+=a[i];

	}

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

	ll cnt=sum/tot;

	if(cnt*tot!=sum){puts("NO");return 0;}

	a[n]=a[0];ll x=0;

	For(i,0,n){

		ll sum=cnt-a[i+1]+a[i];

		ll t=sum/n;

		if(t*n!=sum||t<0||t>cnt){puts("NO");return 0;}

		x+=t;

	}

	if(x!=cnt){puts("NO");return 0;}

	puts("YES");return 0;

}


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

long long a[110000],b[110000];

int main(void)

{

	long long i,j,k=0,n,m,sum=0;

	scanf("%lld",&n);

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

	{

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

		sum=sum+a[i];

	}

	if(sum%(n*(n+1)/2)!=0)

	{

		printf("NO\n");

		return 0;

	}

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

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

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

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

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

	{

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

		{

			printf("NO\n");

			return 0;

		}

		else

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

	}

	if(k==sum)

	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.308339990239865x):
#include <cstdio>

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            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.238471359211669x):
#include <cstdio>

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            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.226175628510284x):
#include <cstdio>

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            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.369000863804185x):
#include <cstdio>

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            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.2706271554783015x):
#include <cstdio>

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            printf("NO\n");

            return 0;

        }

    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: 5.431401672632729x):
#include <cstdio>

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            printf("NO\n");

            return 0;

        }

    printf("YES\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.203977542934455x):
#include <cstdio>

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            printf("NO\n");

            return 0;

        }

    printf("YES\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.228153792512806x):
#include <cstdio>

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            printf("NO\n");

            return 0;

        }

    printf("YES\n");



    return 0;

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

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            printf("NO\n");

            return 0;

        }

    printf("YES\n");



    return 0;

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

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            printf("NO\n");

            return 0;

        }

    printf("YES\n");



    return 0;

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

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<vector>

#include<stack> 

#include<queue>

#include<cmath>

#include<map>

#include<set>

#define LL long long

#define N 100100

#define MOD 1000000007

#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)

#define CLR(a,x) memset(a,x,sizeof(a))

#define INF 0x7fffffff

#define pb push_back

#define X first

#define Y second

using namespace std;

int a[N],d[N];

int main(){

	int n;

	scanf("%d",&n);

	LL sum = 0;

	FOR(i,1,n){

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

		sum += (LL)a[i];

	}

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

	if (sum % s != 0) printf("NO\n");

	else{

		a[n + 1] = a[1];

		int flag = 1;

		FOR(i,1,n){

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

			LL t = sum / s;

			if ((d[i] + t) % n != 0 || d[i] + t < 0){

			   flag = 0;

			   break;

			}

		}

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

		else printf("NO\n");

	}

	

}

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

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            printf("NO\n");

            return 0;

        }

    printf("YES\n");



    return 0;

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

#include <set>

#include <cmath>

#include <queue>

#include <stack>

#include <vector>

#include <cstdio>

#include <string>

#include <cstring>

#include <climits>

#include <cstdlib>

#include <iostream>

#include <algorithm>

using namespace std;

#define Mem(a) memset(a,0,sizeof(a))

#define mem(a) memset(a,-1,sizeof(a))

#define For(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);++(i))

#define FOR(i,l,r) for(int (i)=(int)(l);(i)<=(int)(r);++(i))

#define rof(i,l,r) for(int (i)=(int)(l);(i)>=(int)(r);--(i))

#define all(x) (x).begin(),(x).end()

#define mp make_pair

#define pb push_back

typedef pair<int,int> pii;

typedef vector<pii> vpii;

typedef vector<int> vi;

typedef unsigned long long llu;

typedef long long ll;

const int mxn=1e5+3;

const int inf=INT_MAX;

ll a[mxn],n;

int main(){

	scanf("%lld",&n);

	ll sum=0;

	For(i,0,n){

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

		sum+=a[i];

	}

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

	ll cnt=sum/tot;

	if(cnt*tot!=sum){puts("NO");return 0;}

	a[n]=a[0];ll x=0;

	For(i,0,n){

		ll sum=cnt-a[i+1]+a[i];

		ll t=sum/n;

		if(t*n!=sum||t<0||t>cnt){puts("NO");return 0;}

		x+=t;

	}

	if(x!=cnt){puts("NO");return 0;}

	puts("YES");return 0;

}


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

int a[100001];

int n;

long long int sum = 0,t = 0;

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

    scanf("%d",&n);

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

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

        sum += a[i];

        t += i + 1;

    }



    if (sum % t){

        printf("NO\n");

        return 0;

    }

    int tmp = a[0];

    int d = sum / t;

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

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

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

    

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

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

            printf("NO\n");

            return 0;

        }

    printf("YES\n");



    return 0;

}