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

//#include <sstream>

#include <string>

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <map>

#include <set>

#include <queue>

#include <vector>

#include <cmath>

//#include <functional>

//#define LL long long



using namespace std;





const int maxn = 100005;

long long a[maxn];

long long b[maxn];



int main()

{

//    printf("ok");

#ifdef LOCAL

//    freopen("/Users/ecooodt/Desktop/c++ and acm/DI2_lesson/2/2.txt","r",stdin);

#endif

//    printf("%d",-5%5)

    memset(a,0,sizeof(a));

    long long n,m;

    scanf("%lld",&n);

    long long sum = 0;

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

    {

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

        sum += a[i];

    }

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

    if(sum % t != 0)

    {

        printf("NO\n");

        return 0;

    }

    sum /= t;



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

    {

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

    }

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





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

    {

        b[i] += sum;

        if(b[i] == 0)

        {

            continue;

        }

//        printf("%d\n",b[i]);

        if(b[i] % n != 0 || b[i] < 0)

        {

            printf("NO\n");

            return 0;

        }

    }

    printf("YES\n");

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.806073902106994x):
//by Tipa_Top1

#include <bits/stdc++.h>                   



#define f first

#define s second

#define ll long long 

#define int long long

#define ld long double

#define ull unsigned long long

#define pii pair <int, int>

#define mp make_pair

#define pb push_back

#define pf push_front

#define pp pop_back

#define rev reverse

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

#define sz(s) (int)s.size()

#define forn(i, n) for (int i = 1; i <= n; i++)

#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);

#define nxtp next_permutation

#define pvtp prev_permutation

#define KZ return

#define rep(i, a, b) for(int i = a; i <= b; i++) 



using namespace std;



const int mod = 1e9 + 7;

const int maxn = 1e6 + 111;



int n, a[maxn], sum;



main(){

	cin >> n;



	rep(i, 1, n){

		cin >> a[i];

		sum += a[i];

	}



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

		puts("NO");

		return 0;

	}



	int k = sum / (n * (n + 1) / 2), cur = 0;



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



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

		if (abs(a[i] - a[i - 1] - k) % n){

			puts("NO");

			return 0;

		}

		cur += abs(a[i] - a[i - 1] - k);

	}



	if (cur != k * n)

		puts("NO");

	else

		puts("YES");

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

//#include <sstream>

#include <string>

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <map>

#include <set>

#include <queue>

#include <vector>

#include <cmath>

//#include <functional>

//#define LL long long



using namespace std;





const int maxn = 100005;

long long a[maxn];

long long b[maxn];



int main()

{

//    printf("ok");

#ifdef LOCAL

//    freopen("/Users/ecooodt/Desktop/c++ and acm/DI2_lesson/2/2.txt","r",stdin);

#endif

//    printf("%d",-5%5)

    memset(a,0,sizeof(a));

    long long n,m;

    scanf("%lld",&n);

    long long sum = 0;

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

    {

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

        sum += a[i];

    }

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

    if(sum % t != 0)

    {

        printf("NO\n");

        return 0;

    }

    sum /= t;



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

    {

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

    }

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





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

    {

        b[i] += sum;

        if(b[i] == 0)

        {

            continue;

        }

//        printf("%d\n",b[i]);

        if(b[i] % n != 0 || b[i] < 0)

        {

            printf("NO\n");

            return 0;

        }

    }

    printf("YES\n");

    return 0;

}

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

using namespace std;



typedef long long LL;

const int N = 1e5;



int n;

int li[N+5];



inline LL itung(LL x){

	return ((1LL+x)*x)/2;

}



int main(){

	scanf("%d",&n);

	LL tot = 0LL;

	int idm = 1e9+7;

	int idM = -1;

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

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

		tot+=li[i];

		idm = min(idm,li[i]);

		idM = max(idM,li[i]);

	}

	LL bisa = itung(n);

	if(tot%bisa != 0){

		printf("NO\n");

		return 0;

	}

	int l = -1;

	int r = -1;

	int tmp = n;

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

		if(idm == li[i]){

			l = i;

		}

		if(idM == li[i]){

			r = i;

			if(l!=-1)tmp = min(tmp,r-l+1);

		}

	}

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

		if(idM == li[i]){

			if(l!=-1) tmp = min(tmp,n-(r-l-1));

		}

	}

	sort(li+1,li+n+1);

	if(li[1]*(LL)(tmp) < li[n]){

		printf("NO\n");

	} else {

		printf("YES\n");

	}

	return 0;

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

//#include <sstream>

#include <string>

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <map>

#include <set>

#include <queue>

#include <vector>

#include <cmath>

//#include <functional>

//#define LL long long



using namespace std;





const int maxn = 100005;

long long a[maxn];

long long b[maxn];



int main()

{

//    printf("ok");

#ifdef LOCAL

//    freopen("/Users/ecooodt/Desktop/c++ and acm/DI2_lesson/2/2.txt","r",stdin);

#endif

//    printf("%d",-5%5)

    memset(a,0,sizeof(a));

    long long n,m;

    scanf("%lld",&n);

    long long sum = 0;

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

    {

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

        sum += a[i];

    }

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

    if(sum % t != 0)

    {

        printf("NO\n");

        return 0;

    }

    sum /= t;



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

    {

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

    }

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





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

    {

        b[i] += sum;

        if(b[i] == 0)

        {

            continue;

        }

//        printf("%d\n",b[i]);

        if(b[i] % n != 0 || b[i] < 0)

        {

            printf("NO\n");

            return 0;

        }

    }

    printf("YES\n");

    return 0;

}

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

#define fi first

#define se second

#define pb push_back

#define eb emplace_back

using namespace std;

typedef long long LL;

typedef pair<int,int> pii;

typedef vector<int> vi;



template<class T> inline T re(){

	T N = 0; char c = getchar(); bool neg = 0;

	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';

	for (; c >= '0' && c <= '9'; c = getchar())

		N = (N<<3)+(N<<1) + c - '0';

	return neg ? -N : N;

}



const int mxsz = 1e5 + 3;

int n;

LL a[mxsz], d[mxsz];



inline void CANNOT(){

	puts("NO"); exit(0);

}

int main(){

	n = re<int>();

	for (int i = 1; i <= n; i++) a[i] = re<LL>();

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

	LL totdiff = 0, tot = 0, add = 1LL * n * (n+1) / 2;

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

		totdiff += (d[i] = a[i] - a[i+1]);

		tot += a[i];

	}

	if (tot % add != 0) CANNOT();

	if (totdiff != 0) CANNOT();

	LL m = tot / add;

	LL totx = 0;

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

		if ((d[i] + m) % n != 0){

			CANNOT();

		}

		LL tmp = (d[i] + m) / n;

		if (tmp < 0) CANNOT();

		totx += tmp;

	}

	if (totx != m) CANNOT();

	cout << "YES\n";

	return 0;

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

//#include <sstream>

#include <string>

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <map>

#include <set>

#include <queue>

#include <vector>

#include <cmath>

//#include <functional>

//#define LL long long



using namespace std;





const int maxn = 100005;

long long a[maxn];

long long b[maxn];



int main()

{

//    printf("ok");

#ifdef LOCAL

//    freopen("/Users/ecooodt/Desktop/c++ and acm/DI2_lesson/2/2.txt","r",stdin);

#endif

//    printf("%d",-5%5)

    memset(a,0,sizeof(a));

    long long n,m;

    scanf("%lld",&n);

    long long sum = 0;

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

    {

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

        sum += a[i];

    }

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

    if(sum % t != 0)

    {

        printf("NO\n");

        return 0;

    }

    sum /= t;



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

    {

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

    }

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





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

    {

        b[i] += sum;

        if(b[i] == 0)

        {

            continue;

        }

//        printf("%d\n",b[i]);

        if(b[i] % n != 0 || b[i] < 0)

        {

            printf("NO\n");

            return 0;

        }

    }

    printf("YES\n");

    return 0;

}

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

using namespace std;

int main(){

	long long n;

	cin >> n;

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

	long long arr[n];

	long long sum = 0;

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

		cin >> arr[i];

		sum += arr[i];

	}

	if(sum % sn != 0){

		cout << "NO" <<endl;

		return 0;

	}

	long long ans = 1;

	long long cnt = sum/sn;

	long long awal = cnt;

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

		long long z = awal;

		while(arr[i]+z != arr[(i+1)%n]){

			cnt--;

			z-=n;

			if(arr[i]+z <  arr[(i+1)%n]){

				ans = 0;

				break;

			}

		}

		if(ans == 0)break;

	}

	if(cnt != 0 || ans == 0)cout<<"NO"<<endl;

	else cout<<"YES"<<endl;

	

	

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

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

using namespace std;



#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)

#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)

#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)

#define all(v) begin(v), end(v)

#define pb(a) push_back(a)

#define fr first

#define sc second

#define INF 2000000000

#define int long long int



#define X real()

#define Y imag()

#define EPS (1e-10)

#define EQ(a,b) (abs((a) - (b)) < EPS)

#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )

#define LE(n, m) ((n) < (m) + EPS)

#define LEQ(n, m) ((n) <= (m) + EPS)

#define GE(n, m) ((n) + EPS > (m))

#define GEQ(n, m) ((n) + EPS >= (m))



typedef vector<int> VI;

typedef vector<VI> MAT;

typedef pair<int, int> pii;

typedef long long ll;



typedef complex<double> P;

typedef pair<P, P> L;

typedef pair<P, double> C;



int dy[]={0, 0, 1, -1};

int dx[]={1, -1, 0, 0};

int const MOD = 1000000007;



namespace std {

    bool operator<(const P& a, const P& b) {

        return a.X != b.X ? a.X < b.X : a.Y < b.Y;

    }

}



signed main() {

    int n; cin >> n;

    int a[100010] = {};

    int sum = 0;



    rep(i,0,n) {

        cin >> a[i];

        sum += a[i];

    }



    int cs[100010] = {};

    int ret[100010] = {};

    int cntnum = 0;



    if(sum % (n * (n+1) / 2)) cout << "NO" << endl;

    else {

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

        rep(i,0,n) {

            int prev = (i - 1 + n) % n;

            int s = a[prev] - a[i];

            if( (s+cntnum) % n != 0 || (s + cntnum) / n < 0) {

                cout << "NO" << endl;

                return 0;

            }

            cs[i] += (s + cntnum) / n;

        }

        rep(i,0,n) ret[0] += cs[i] * ((n - i) % n + 1);

        rep(i,1,n) ret[i] = ret[i-1] - cs[i] * n + cntnum;

        rep(i,0,n) {

            if(ret[i] != a[i]) {

                cout << "NO" << endl;

                return 0;

            }

        }

        cout << "YES" << endl;

    }

    return 0;

}

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

using namespace std;



long long int N, A[100010];

int main() {

    scanf("%lld", &N);

    long long int sum = 0, div = N*(N+1)/2;

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

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

        sum += A[i];

    }



    bool ok = (sum % div == 0);

    long long int sum_op = sum / div;

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

        long long int val = A[i] - A[(i+1)%N] + sum_op;

        ok &= (val >= 0 && val % N == 0);

    }

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

    return 0;

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

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

using namespace std;



#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)

#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)

#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)

#define all(v) begin(v), end(v)

#define pb(a) push_back(a)

#define fr first

#define sc second

#define INF 2000000000

#define int long long int



#define X real()

#define Y imag()

#define EPS (1e-10)

#define EQ(a,b) (abs((a) - (b)) < EPS)

#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )

#define LE(n, m) ((n) < (m) + EPS)

#define LEQ(n, m) ((n) <= (m) + EPS)

#define GE(n, m) ((n) + EPS > (m))

#define GEQ(n, m) ((n) + EPS >= (m))



typedef vector<int> VI;

typedef vector<VI> MAT;

typedef pair<int, int> pii;

typedef long long ll;



typedef complex<double> P;

typedef pair<P, P> L;

typedef pair<P, double> C;



int dy[]={0, 0, 1, -1};

int dx[]={1, -1, 0, 0};

int const MOD = 1000000007;



namespace std {

    bool operator<(const P& a, const P& b) {

        return a.X != b.X ? a.X < b.X : a.Y < b.Y;

    }

}



signed main() {

    int n; cin >> n;

    int a[100010] = {};

    int sum = 0;



    rep(i,0,n) {

        cin >> a[i];

        sum += a[i];

    }



    int cs[100010] = {};

    int ret[100010] = {};

    int cntnum = 0;



    if(sum % (n * (n+1) / 2)) cout << "NO" << endl;

    else {

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

        rep(i,0,n) {

            int prev = (i - 1 + n) % n;

            int s = a[prev] - a[i];

            // n で割り切れなければ操作回数が小数になるので不適

            // 結果が負になるのも不適 (操作回数は非負整数)

            if( (s+cntnum) % n != 0 || (s + cntnum) / n < 0) {

                cout << "NO" << endl;

                return 0;

            }

            cs[i] += (s + cntnum) / n;

        }

        /*

        rep(i,0,n) ret[0] += cs[i] * ((n - i) % n + 1);

        rep(i,1,n) ret[i] = ret[i-1] - cs[i] * n + cntnum;

        rep(i,0,n) {

            if(ret[i] != a[i]) {

                cout << "NO" << endl;

                return 0;

            }

        }

        */

        cout << "YES" << endl;

    }

    return 0;

}

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

using namespace std;



long long int N, A[100010];

int main() {

    scanf("%lld", &N);

    long long int sum = 0, div = N*(N+1)/2;

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

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

        sum += A[i];

    }



    bool ok = (sum % div == 0);

    long long int sum_op = sum / div;

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

        long long int val = A[i] - A[(i+1)%N] + sum_op;

        ok &= (val >= 0 && val % N == 0);

    }

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

    return 0;

}
// Slower C++ solution:
// be name khoda

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

#define pb push_back

const ll maxn=3*1e5+5;

ll a[maxn];

int main()

{

	ll n;cin >> n;

	ll s=0; ll s1=n*(n+1)/2;

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

	{

		cin >> a[i];

		s+=a[i];

	}

	if (n==1)

	{

		cout << "YES";

		return 0;

	}

	if (s%s1!=0)

	{

		cout << "NO";

		return 0;

	}

	s1=s/s1;

	ll s2=s1; ll y=0;

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

	{

		y=a[i]-a[(i+1)%n]+s1;

		if (y<0 || y%n)

		{

			cout << "NO";

			return 0;

		}

		s2-=y/n;

	}

	if (s2==0) cout<<"YES"; else cout<<"NO"; 

}


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

#include<cstring>

#include<algorithm>

#include<cmath>

#define MN 100005

using namespace std;

typedef long long ll;

int n,a[MN],b[MN];ll sum;

int main(){

	scanf("%d",&n);

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

	if(sum%(1ll*n*(n+1)/2))return 0*puts("NO");ll round=sum/(1ll*(n+1)*n/2);

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

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

		b[i]-=round;

		if(b[i]>0||b[i]%n)return 0*puts("NO");

	}puts("YES");

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define fbo find_by_order

#define ook order_of_key



typedef long long ll;

typedef pair<ll,ll> ii;

typedef vector<int> vi;

typedef long double ld; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

typedef set<int>::iterator sit;

typedef map<int,int>::iterator mit;

typedef vector<int>::iterator vit;



ll n;

ll a[100001];



int main()

{

	ios_base::sync_with_stdio(0); cin.tie(0);

	cin>>n;

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

	{

		cin>>a[i];

	}

	ll sum = 0;

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

	{

		sum+=a[i];

	}

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

	if(sum%tot==0)

	{

		ll xsum = sum/tot;

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

		{

			int u = i; int v = i-1;

			if(u==n) u=0;

			ll diff = a[u] - a[v];

			ll nx2 = xsum - diff;

			if(nx2<0)

			{

				cout<<"NO\n";

				return 0;

			}

			if(nx2%n==0)

			{

				

			}

			else

			{

				cout<<"NO\n";

				return 0;

			}

		}	

		cout<<"YES\n";

	}

	else

	{

		cout<<"NO\n";

	}

}


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

#include<cstring>

#include<algorithm>

#include<cmath>

#define MN 100005

using namespace std;

typedef long long ll;

int n,a[MN],b[MN];ll sum;

int main(){

	scanf("%d",&n);

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

	if(sum%(1ll*n*(n+1)/2))return 0*puts("NO");ll round=sum/(1ll*(n+1)*n/2);

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

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

		b[i]-=round;

		if(b[i]>0||b[i]%n)return 0*puts("NO");

	}puts("YES");

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

#include<iostream>

#include<string>

#include<vector>

#include<map>

using namespace std;

#define pb push_back

#define mp make_pair

#define fi first

#define se second



typedef long long ll;

typedef long double ld;

typedef unsigned long long  ull;

typedef vector<int> vi;



struct pp{ll x,y;};



const int base = 1000*1000*1000;

const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

const int inf = (int)1e9;

const int mod = 1e9+7;

ll gcd (ll a, ll b) {

        while (b) {

            a %= b;

            swap (a, b);

        }

        return a;

}



/*

void quickSort(int left, int right) {

      int i = left, j = right;

      pp tmp;

      int pivot = a[(left + right) / 2].x;

      while (i <= j) {

            while (a[i].x < pivot)

                  i++;

            while (a[j].x > pivot)

                  j--;

            if (i <= j) {

                 swap(a[i],a[j]);

                  i++,j--;

            }

      };

    if (left < j)

            quickSort(left, j);

      if (i < right)

            quickSort(i, right);

}*/

ll binpow (ll a, ll n) {

	ll res = 1;

	while (n) {

		if (n & 1)

			res *= a,res %= mod;

		a *= a,a %= mod;

		n >>= 1;

	}

	return res;

}

const int MaxN = 1e5 + 17;

ll a[111111],n,sum;

int main(){

    cin>>n;

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

        cin>>a[i];

        sum+=a[i];

    }

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

        cout<<"NO";

        return 0;

    }

    ll x=sum/(n*(n+1)/2),cnt=0;

    for(ll i=0;i<n;i++)if(a[i]<x){

        cout<<"NO";

        return 0;

    }

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

        ll b=a[i%n]-a[i-1];

        if(abs(b+(n-1)*x)%n||b+(n-1)*x<0){

            cout<<"NO";

            return 0;

        }

        else cnt+=x-(b+(n-1)*x)/n;

    }

    cout<<"YES";



    return 0;

}


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

#include<cstring>

#include<algorithm>

#include<cmath>

#define MN 100005

using namespace std;

typedef long long ll;

int n,a[MN],b[MN];ll sum;

int main(){

	scanf("%d",&n);

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

	if(sum%(1ll*n*(n+1)/2))return 0*puts("NO");ll round=sum/(1ll*(n+1)*n/2);

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

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

		b[i]-=round;

		if(b[i]>0||b[i]%n)return 0*puts("NO");

	}puts("YES");

}
// Slower C++ solution:
// be name khoda

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

#define pb push_back

const ll maxn=3*1e5+5;

ll a[maxn];

int main()

{

	ll n;cin >> n;

	ll s=0; ll s1=n*(n+1)/2;

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

	{

		cin >> a[i];

		s+=a[i];

	}

	if (n==1)

	{

		cout << "YES";

		return 0;

	}

	if (s%s1!=0)

	{

		cout << "NO";

		return 0;

	}

	s1=s/s1;

	ll s2=s1; ll y=0;

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

	{

		y=a[i]-a[(i+1)%n]+s1;

		if (y<0 || y%n)

		{

			cout << "NO";

			return 0;

		}

		s2-=y/n;

	}

	if (s2==0) cout<<"YES"; else cout<<"NO"; 

}


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

#include<cctype>

#include<cstring>

#include<cmath>

#include<algorithm>

#define max(a,b) (a>b?a:b)

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

#define reg register

typedef long long ll;

template<typename T>inline T read(){

    reg T x=0;reg short f=1;reg char c=getchar();

    for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());

    for(;isdigit(c);x=x*10+(c^48),c=getchar());

    return x*f;

}

const int maxn=1e5+5;

int n;

ll a[maxn],s[maxn],sum;

int main(){

	n=read<int>();for(reg int i=1;i<=n;i++)sum+=(a[i]=read<int>());a[0]=a[n];

	if(sum%(1ll*n*(n+1)/2))return 0*puts("NO");reg int cnt=sum/(1ll*n*(n+1)/2);

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

	for(reg int i=1;i<=n;i++)if(s[i]<0||s[i]%n)return 0*puts("NO");

	return 0*puts("YES");

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define fbo find_by_order

#define ook order_of_key



typedef long long ll;

typedef pair<ll,ll> ii;

typedef vector<int> vi;

typedef long double ld; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

typedef set<int>::iterator sit;

typedef map<int,int>::iterator mit;

typedef vector<int>::iterator vit;



ll n;

ll a[100001];



int main()

{

	ios_base::sync_with_stdio(0); cin.tie(0);

	cin>>n;

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

	{

		cin>>a[i];

	}

	ll sum = 0;

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

	{

		sum+=a[i];

	}

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

	if(sum%tot==0)

	{

		ll xsum = sum/tot;

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

		{

			int u = i; int v = i-1;

			if(u==n) u=0;

			ll diff = a[u] - a[v];

			ll nx2 = xsum - diff;

			if(nx2<0)

			{

				cout<<"NO\n";

				return 0;

			}

			if(nx2%n==0)

			{

				

			}

			else

			{

				cout<<"NO\n";

				return 0;

			}

		}	

		cout<<"YES\n";

	}

	else

	{

		cout<<"NO\n";

	}

}


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

#include<cctype>

#include<cstring>

#include<cmath>

#include<algorithm>

#define max(a,b) (a>b?a:b)

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

#define reg register

typedef long long ll;

template<typename T>inline T read(){

    reg T x=0;reg short f=1;reg char c=getchar();

    for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());

    for(;isdigit(c);x=x*10+(c^48),c=getchar());

    return x*f;

}

const int maxn=1e5+5;

int n;

ll a[maxn],s[maxn],sum;

int main(){

	n=read<int>();for(reg int i=1;i<=n;i++)sum+=(a[i]=read<int>());a[0]=a[n];

	if(sum%(1ll*n*(n+1)/2))return 0*puts("NO");reg int cnt=sum/(1ll*n*(n+1)/2);

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

	for(reg int i=1;i<=n;i++)if(s[i]<0||s[i]%n)return 0*puts("NO");

	return 0*puts("YES");

}