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

#include <set>

#include <cstring>

#include <algorithm>

#include <queue>

#include <cstdio>

#include <map>

#include <math.h>

#define LL long long

using namespace std;

LL n;

int a[100005];

int main()

{

    scanf("%d",&n);

    LL sum=0;

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

    {

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

        sum+=a[i];

    }

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

    if(sum%nn!=0)

    {

        cout<<"NO"<<endl;

    }

    else

    {

        LL k=sum/nn;

        int temp=a[0]-a[n-1];

        for(int i=n-1;i>0;i--)

        {

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

        }

        a[0]=temp;

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

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

        {

            cout<<"NO"<<endl;

            return 0;

        }

        cout<<"YES"<<endl;

    }

    return 0;



}


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

const int maxn = 100005;

#define ll long long

ll a[maxn];

ll dis[maxn];





int main()

{

	ll n,i;

	scanf("%lld",&n);

	ll sum = 0;

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

	{

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

		if(i >= 2)

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

		sum += a[i];

	}

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

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

	{

		printf("NO\n");

		return 0;

	}

	else

	{

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

		ll ans = 0;

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

		{

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

			{

				printf("NO\n");

				return 0;

			}

			else

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

		}

		if(ans != sum)

			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.8213068586630767x):
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Coder:LCJ

Prob:Boxes :AtCoder - 2303

Type:math

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#include <iostream>

#include <cstdlib>

#include <cstring>

#include <cstdio>

#include <cmath>

#include <algorithm>

#include <stack>

#include <list>

#include <queue>

#include <vector>

#include <map>

#include <set>

#include <sstream>

#define MEM(a,b) memset(a,b,sizeof(a)) 

#define sint(x) scanf("%d",&(x))

#define sint2(x,y) scanf("%d%d",&(x),&(y))

#define rep(x,y,z) for(int (x)=(y);(x)<(z);++(x))

using namespace std;

typedef long long ll;

const int maxn=10000000+10;

const int mod=1000000007;

bool flag;

ll n,sum,s;

ll a[100005];

int main()

{

	flag=true;

	scanf("%lld",&n);

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

	{

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

		sum+=a[i];

	}

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

	{

		flag=false;

		printf("NO\n");

	}

	else

	{

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

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

		{

			ll j=(i+1)>=n?0:i+1;

			if( (s-(a[j]-a[i]))<0 || (s-(a[j]-a[i]))%n )

			{

				flag=false;

				printf("NO\n");

				break;

			}

		}

	}

	if(flag)

	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.797480688576819x):
#include <bits/stdc++.h>

using namespace std;



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

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)

#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a, value) memset(a, value, sizeof(a))



#define SZ(a) (int) a.size()

#define ALL(a) a.begin(),a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const LL INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 100100;



LL A[MAX];

LL B[MAX];



int main()

{

	//freopen("in.txt", "r", stdin);

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



	int n;

	scanf("%d", &n);



	LL sum = 0;



	FOR (i, 0, n)

	{

		int x;

		scanf("%d", &x);

		A[i] = x;



		sum += A[i];

	}



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



	if (sum % b != 0)

	{

		cout<<"NO"<<endl;

		return 0;

	}



	LL cnt = sum / b;



	FOR (i, 0, n)

	{

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

	}



	FOR (i, 0, n)

	{

		B[i] -= cnt;

	}



	LL x = 0;

	FOR (i, 0, n)

	{

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

		{

			cout<<"NO"<<endl;

			return 0;

		}



		x += abs(B[i] / n);

	}



	if (x == cnt) cout<<"YES"<<endl;

	else cout<<"NO"<<endl;





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

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

using namespace std;



#define F(i, n) for(int i = 0; i < n; ++i)

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

#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)

#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a,value) memset(a, value, sizeof(a))



#define SZ(a) (int)a.size()

#define ALL(a) a.begin(), a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL) INF;



const int MAX = 200*1000+47;



LL A[MAX];

int main()

{

    int n;

    scanf("%d", &n);

    LL s = 0;

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

    FOR(i, 0, n)

    {

        scanf("%d", A + i);

        s += A[i];

    }

    A[n] = A[0];

    if (s % k)

    {

        printf("NO");

        return 0;

    }

    FOR(i, 0, n)

    {

        LL d = s/k - (A[i+1] - A[i]);

        if ( d < 0 || d % n)

        {

            printf("NO");

            return 0;

        }

    }

    printf("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.8272104135879232x):
#include<bits/stdc++.h>

#define ll long long

using namespace std;

int n,a[100005],s[100005];

ll sum,turn;

bool flag=1;

inline int read(){

    int x=0,f=1;char ch=getchar();

    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}

    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}

    return x*f;

}

int main(){

    n=read();

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

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

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

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

    for(int i=1;i<=n;++i) if(s[i]-turn>0||(-s[i]+turn)%n) flag=0;

    if(flag) puts("YES");

	else puts("NO");

}
// 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.8192370692073858x):
// Why am I so dumb? :c

#include<bits/stdc++.h>



#define pb push_back

#define mp make_pair



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



#define fi first

#define se second



using namespace std;



typedef long long ll;



const int MAXN = (int)1e5 + 5;



ll arr[MAXN];



int n;



void solve() {

	scanf("%d", &n);

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



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

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

		sum += arr[i];

	}



	if (sum % k) {

		printf("NO\n");

		return;

	}



	sum /= k;



	{

		vector<ll> tmp(n + 1);

		arr[n + 1] = arr[1];



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

			tmp[i] = arr[i + 1] - arr[i];

		}



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

			arr[i] = tmp[i];

		}         

	}



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

		arr[i] -= sum;

	}



	ll cur = 0;



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

		if (arr[i] > 0) {

			printf("NO\n");

			return;

		}



		ll x = -arr[i];



		if (x % n) {

			printf("NO\n");

			return;

		}



		cur += x / n;

	}



	if (cur != sum) {

		printf("NO\n");

		return;

	}         



	printf("YES\n");

}



int main() {

    int tt = 1;



    while (tt--) {

        solve();

    }



    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.7757846981936056x):
#include <bits/stdc++.h>



#define F first

#define S second

#define mp make_pair

#define pb push_back

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



using namespace std;



typedef long long ll;

typedef long double ld;



const int N = (int)2e5 + 123;

const int mod = 1e9 + 7;

const ll inf = 1e18 + 9;



inline void boost () {

	ios_base::sync_with_stdio (0);

	cin.tie (0), cout.tie (0);

}

ll n, a[N];



int main () {

	boost ();

	cin >> n;

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

	ll sum = 0;

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

	if (sum % (n * (n + 1) / 2) != 0) return cout << "NO", 0;

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

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

		if ((a[i] - a[i - 1] - need) % n != 0 || a[i] - a[i - 1] > need)

			return cout << "NO", 0;

	cout << "YES";

	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.8020832724094444x):
#include <bits/stdc++.h>

                                               

//#pragma comment(linker, "/stack:200000000")

//#pragma GCC optimize("Ofast")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")



#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);                                          

#define mp make_pair

#define pb push_back

#define f first

#define s second

#define int ll

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

#define forev(i, b, a) for(int i = (b); i >= (a); --i)

#define VAR(v, i) __typeof(i) v=(i)

#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

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

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



using namespace std;



typedef long long ll;

typedef long double ld;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi; 

typedef vector<ll> Vll;

typedef vector<pair<int, int> > vpii;

typedef vector<pair<ll, ll> > vpll;



const int maxn = (int)1e5 + 100;

const int mod = (int) 2e9 + 7;

const int inf = mod;



int n, a[maxn], tot;  

main () {         

  srand(time(0));

  scanf("%d", &n);

  int sum = 0;

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

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

    cout << "NO";

    return 0;

  }

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

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

  forn(i, 1, n){

    if(a[i + 1] - a[i] - need > 0){

      cout << "NO";

      return 0;

    }

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

      cout << "NO";

      return 0;

    }

    tot += abs(a[i + 1] - a[i] - need);  

  }                                  

  if(tot != need * n) cout << "NO";

  else cout << "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.776017202360013x):
///Made By Imangali



#include <bits/stdc++.h>



#define pb push_back

#define int long long

#define eb emplace_back

#define mp make_pair

#define f first

#define s second

#define pii pair<int, int>

#define forit(it, s) for(auto it: s)

#define AddSpeed cin.tie(0); ios_base :: sync_with_stdio(0);

#define fixset(x) cout << fixed << setprecision(x)

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

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

#define sqr(x) ((x) * 1ll * (x))

#define fname "A"

#define vi vector<int>

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

#define vpii vector<pair<int,int>                         



typedef long long ll;

typedef unsigned long long ull;

typedef double ld;

typedef long double lld;



const int INF = 1e9 + 7;

const ld EPS = 1e-9;

const ld pi = acos(-1);

const int mod = 998244353;

const int N = 500 + 7;

const int maxn = 3e5 + 7;

using namespace std;



inline void time() {

	cerr << (clock() * 1.0 / CLOCKS_PER_SEC * 1.0);

}

int n, a[maxn];

main() { AddSpeed

	cin >> n;

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

		cin >> a[i];

	int k = 0, s = 0;

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

  	s += i;

  	k += a[i];

	}

	if(k % s != 0) {

		cout<<"NO";

		return 0;

	}

	k /= s;

	vector <int> st;  

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

		st.pb(a[i + 1] - a[i]);

	st.pb(a[1] - a[n]);



	for(auto x : st) {      	

		if(x > k) {

			cout<<"NO";

			return 0;

		}

		if((k - x) % n != 0) {

			cout<<"NO";

			return 0;

		}

	}

	cout<<"YES";



	return 0;                                                                                                           

}