#include<bits/stdc++.h>
using namespace std;
#define ll long long int
/*int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<4*(sqrt(a*c/b)+sqrt(a*b/c)+sqrt(b*c/a))<<endl;
    return 0;
}
*/
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    vector<int>a;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        a.push_back(x);
    }

    int cnt=0;
    for(int j=0; j<n; j++)
    {
        for(int i=0; i<n; i++)
        {
            int x=i+1;
            if(x%2!=0)
            {
                if(a[i]==n-1)
                {
                    a[i]=0;
                }
                else
                {
                    a[i]+=1;
                }
            }
            else
            {
                if(a[i]==0)
                {
                    a[i]=n-1;
                }
                else
                {
                    a[i]-=1;
                }
            }
        }
        for(int k=0; k<n; k++)
        {
            //cout<<a[k]<<" ";
            if(a[k]==k)
            {
                cnt++;
            }
        }
        if(cnt==n)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        cnt=0;
    }
    cout<<"No"<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
/*int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<4*(sqrt(a*c/b)+sqrt(a*b/c)+sqrt(b*c/a))<<endl;
    return 0;
}
*/
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    vector<int>a;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        a.push_back(x);
    }

    int cnt=0;
    for(int j=0; j<n; j++)
    {
        for(int i=0; i<n; i++)
        {
            int x=i+1;
            if(x%2!=0)
            {
                if(a[i]==n-1)
                {
                    a[i]=0;
                }
                else
                {
                    a[i]+=1;
                }
            }
            else
            {
                if(a[i]==0)
                {
                    a[i]=n-1;
                }
                else
                {
                    a[i]-=1;
                }
            }
            //cout<<a[i]<<" ";
            if(a[n-1]==n-1)
            {
                //cout<<"yes";
                goto Label;
            }

        }
    }
    Label:
    for(int i=0;i<n;i++)
    {
        if(a[i]==i)
        {
            cnt++;
        }
    }
    if(cnt==n)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
#define sz(a) ll((a).size())
#define mset(a,x) memset(a,x,sizeof(a))
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define all(c) (c).begin(),(c).end()
#define test() ll t;cin>>t;while(t--)
#define inputar(ar,n) ll n;cin>>n;ll ar[n];rep(i,0,n)cin>>ar[i]
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define debug(x) cout << (#x) << " is " << (x) << endl
const ll MAX = 1e6;

//POWER FUNCTION
ll power(ll a,ll b,ll m){
    ll r=1;
    while(b){
        if(b%2==1)
            r=(r*a)%m;
        b/=2;
        a=(a*a)%m;
    }
    return r;
}

//SIEVE OF ERATOSTHENES
bool prime[MAX];//MAX can be 'n'
void sieve(ll n)
{
    mset(prime,true);
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*2; i<=n; i += p)
                prime[i] = false;
        }
    }
    // Print all prime numbers
    for (int p=2; p<=n; p++){
       if (prime[p])
          cout << p << " ";
    }
}

//PRIME FACTORS OF A NUMBER
map<ll,ll>pfactors;
void pfact(ll n){
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0){
            while(n%i==0){
                pfactors[i]++;
                n/=i;
            }
        }
    }
    if(n>1)
        pfactors[n]++;
    //Print all prime factors with their frequency
    for(auto it:pfactors){
        cout<<it.ff<<" -> "<<it.ss<<endl;
    }
    //Write pfactors.clear() after each test case
}

//SOLVE
void solve(){
    inputar(ar,n);
    ll cnt[n];
    rep(i,0,n){
        if(i%2==0){
            if(i>=ar[i]){
                cnt[i]=abs(ar[i]-i);
            }
            else{
                cnt[i]=n-abs(ar[i]-i);
            }
        }
        else{
            if(i>ar[i]){
                cnt[i]=n-abs(ar[i]-i);
            }
            else{
                cnt[i]=abs(ar[i]-i);
            }
        }
//        debug(i);
//        debug(cnt[i]);
    }
    ll f=cnt[0];
//    rep(i,0,n)cout<<"cnt "<<cnt[i]<<endl;
    rep(i,0,n){
        if(cnt[i]!=f){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
    return;

}

//MAIN PROGRAM
int main() {
//    IOS;
//    test()
        solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
#define sz(a) ll((a).size())
#define mset(a,x) memset(a,x,sizeof(a))
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define all(c) (c).begin(),(c).end()
#define test() ll t;cin>>t;while(t--)
#define inputar(ar,n) ll n;cin>>n;ll ar[n];rep(i,0,n)cin>>ar[i]
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define debug(x) cout << (#x) << " is " << (x) << endl
const ll MAX = 1e6;

//POWER FUNCTION
ll power(ll a,ll b,ll m){
    ll r=1;
    while(b){
        if(b%2==1)
            r=(r*a)%m;
        b/=2;
        a=(a*a)%m;
    }
    return r;
}

//SIEVE OF ERATOSTHENES
bool prime[MAX];//MAX can be 'n'
void sieve(ll n)
{
    mset(prime,true);
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*2; i<=n; i += p)
                prime[i] = false;
        }
    }
    // Print all prime numbers
    for (int p=2; p<=n; p++){
       if (prime[p])
          cout << p << " ";
    }
}

//PRIME FACTORS OF A NUMBER
map<ll,ll>pfactors;
void pfact(ll n){
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0){
            while(n%i==0){
                pfactors[i]++;
                n/=i;
            }
        }
    }
    if(n>1)
        pfactors[n]++;
    //Print all prime factors with their frequency
    for(auto it:pfactors){
        cout<<it.ff<<" -> "<<it.ss<<endl;
    }
    //Write pfactors.clear() after each test case
}

//SOLVE
void solve(){
    inputar(ar,n);
    ll cnt[n];
    rep(i,0,n){
        if(i%2==0){
            if(i>ar[i]){
                cnt[i]=abs(ar[i]-i);
            }
            else{
                cnt[i]=n-abs(ar[i]-i);
            }
        }
        else{
            if(i>ar[i]){
                cnt[i]=n-abs(ar[i]-i);
            }
            else{
                cnt[i]=abs(ar[i]-i);
            }
        }
//        debug(i);
//        debug(cnt[i]);
    }
    ll f=cnt[0];
//    rep(i,0,n)cout<<"cnt "<<cnt[i]<<endl;
    rep(i,0,n){
        if(cnt[i]!=f){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
    return;

}

//MAIN PROGRAM
int main() {
//    IOS;
//    test()
        solve();
    return 0;
}


#pragma comment(linker, "/STACK:10000000000")
#define forn(from, to, i) for (int i = from; i < to; ++i)
#define fron(from, to, i) for (int i = from; i >= to; --i)
    //#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
    //#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
    //#pragma GCC target("avx,avx2")
    //#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <stdint.h>
#include <cstdint>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <cstring>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <time.h>
#include <deque>
#include <functional>
using namespace std;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
#define int long long
#define m_p make_pair
#define all(x) x.begin(), x.end()
#define pii pair <int, int>
#define pb push_back
#define ff first
#define x1 x11337
#define y1 y11337
#define ss second
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define vi vector<int>
#define si set<int>
#define spii set<pair<int, int> >
#define mii map<int, int>
#define vvi vector<vi>
#define sz(x) (int)((x).size())
#define vpii vector<pii>
template<typename T> ostream& operator<<(ostream& o, vector<T> x) { for (auto it : x) o << it << ' '; return o; }
template<typename T> istream& operator>>(istream& i, vector<T>& x) { for (auto& it : x) i >> it; return i; }
template <typename T1, typename T2> void chkmin(T1& a, T2 b) { a > b ? a = b : 0; }
template <typename T1, typename T2> void chkmax(T1& a, T2 b) { a < b ? a = b : 0; }
const int INF = 1000000007;
const int INF2 = 100000000000000007;
const int miniINF = 1e15;
const int MOD1 = 998244353;
const int MOD = 1000000007;
const int SIZE = 100010;
const int base = 53;
const ldb eps = 1e-6;
const db pi = acos(-1.0);
int add(int a, int b) {
    return ((a + b) % MOD + MOD) % MOD;
}
int mult(int a, int b) {
    return (a * b) % MOD;
}
int binpow(int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1) res = mult(res, a);
        a = mult(a, a);
        n >>= 1;
    }
    return res;
}
int inv(int a) {
    return binpow(a, MOD - 2);
}
int del(int a, int b) {
    return mult(a, inv(b));
}

int n, m, l, r, rs, a[SIZE];
string s;
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    double cl = clock();
#endif
    cin >> n;
    vi a(n);
    cin >> a;
    m = n - a[0];
    a[0] = 0;
    forn(1, n, i) {
        if (i % 2)
            a[i] = ((a[i] - m) + n) % n;
        else a[i] = (a[i] + m) % n;
    }
    bool ok = 1;
    forn(0, n, i) {
        ok &= a[i] == i;
    }
    cout << ok ? "Yes" : "No";
#ifdef _DEBUG
    cout << "\n\n" << (clock() - cl) / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


#pragma comment(linker, "/STACK:10000000000")
#define forn(from, to, i) for (int i = from; i < to; ++i)
#define fron(from, to, i) for (int i = from; i >= to; --i)
    //#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
    //#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
    //#pragma GCC target("avx,avx2")
    //#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <stdint.h>
#include <cstdint>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <cstring>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <time.h>
#include <deque>
#include <functional>
using namespace std;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
#define int long long
#define m_p make_pair
#define all(x) x.begin(), x.end()
#define pii pair <int, int>
#define pb push_back
#define ff first
#define x1 x11337
#define y1 y11337
#define ss second
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define vi vector<int>
#define si set<int>
#define spii set<pair<int, int> >
#define mii map<int, int>
#define vvi vector<vi>
#define sz(x) (int)((x).size())
#define vpii vector<pii>
template<typename T> ostream& operator<<(ostream& o, vector<T> x) { for (auto it : x) o << it << ' '; return o; }
template<typename T> istream& operator>>(istream& i, vector<T>& x) { for (auto& it : x) i >> it; return i; }
template <typename T1, typename T2> void chkmin(T1& a, T2 b) { a > b ? a = b : 0; }
template <typename T1, typename T2> void chkmax(T1& a, T2 b) { a < b ? a = b : 0; }
const int INF = 1000000007;
const int INF2 = 100000000000000007;
const int miniINF = 1e15;
const int MOD1 = 998244353;
const int MOD = 1000000007;
const int SIZE = 100010;
const int base = 53;
const ldb eps = 1e-6;
const db pi = acos(-1.0);
int add(int a, int b) {
    return ((a + b) % MOD + MOD) % MOD;
}
int mult(int a, int b) {
    return (a * b) % MOD;
}
int binpow(int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1) res = mult(res, a);
        a = mult(a, a);
        n >>= 1;
    }
    return res;
}
int inv(int a) {
    return binpow(a, MOD - 2);
}
int del(int a, int b) {
    return mult(a, inv(b));
}

int n, m, l, r, rs, a[SIZE];
string s;
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    double cl = clock();
#endif
    cin >> n;
    vi a(n);
    cin >> a;
    m = n - a[0];
    a[0] = 0;
    forn(1, n, i) {
        if (i % 2)
            a[i] = ((a[i] - m) + n) % n;
        else a[i] = (a[i] + m) % n;
    }
    bool ok = 1;
    forn(0, n, i) {
        ok &= a[i] == i;
    }
    cout << (ok ? "Yes" : "No");
#ifdef _DEBUG
    cout << "\n\n" << (clock() - cl) / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


#include <iostream>
#include <math.h>

#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_set>
#include <utility>
#include <cstdlib>
#include <fstream>
#include <stdio.h>
#include <utility>
#include <ctype.h>
#include <cassert>
#include <list>
#include <numeric>
#define eps 1e-8
#define ll long long
#define ld long double
#define ed cout<<endl
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define inf 2e9
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define sz 1456789
#define all(x) x.begin(), x.end()
#define pi 3.14159265359
#define M 1000000007

using namespace std;

ll a, b, m, n, x, k, c, y, z, i, j, r, u, cnt, ans, sum, maxx;
ld d, h[123][123], p[55][55], v, e;
ll na, ma, nb, mb;
ll br[sz], ar[sz], mn[sz], mx[sz], used[sz];
char g[123][123];
string s[sz], t, ress;
vector < ll > vec, as;
map < ll, ll> mmap;
set <ll> ss;
bool ok, oka[sz];
char ch;
map<pair<int, int>, int>    mpp;

ll bpow(ll v, ll u, ll mod){
    if(!u) return 1;
    ll res = bpow(v, u / 2, mod);
    res = (res * 1ll * res) % mod;
    if(u & 1) res = (res * 1ll * v) % mod;
    return res;
}

ll gcd(ll a, ll b){
    if(a > b) swap(a, b);
    if(!a)    return b;
    return gcd(b % a, a);
}

void dii(){
    cin >> n;
    cin >> n >> b;
    for(int i = 1;i < n; i++){
        cin >> a;
        if((i % 2 == 0 && (n - b + a) % n != i) || (i % 2 != 0 && (b + a) % n != i)){
            cout << "NO";
            return;
        }
    }
    cout<<"YES";
}
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q = 1;
    //cin >> q;
    while(q--) dii();
    return 0;
}


#include <iostream>
#include <math.h>

#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_set>
#include <utility>
#include <cstdlib>
#include <fstream>
#include <stdio.h>
#include <utility>
#include <ctype.h>
#include <cassert>
#include <list>
#include <numeric>
#define eps 1e-8
#define ll long long
#define ld long double
#define ed cout<<endl
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define inf 2e9
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define sz 1456789
#define all(x) x.begin(), x.end()
#define pi 3.14159265359
#define M 1000000007

using namespace std;

ll a, b, m, n, x, k, c, y, z, i, j, r, u, cnt, ans, sum, maxx;
ld d, h[123][123], p[55][55], v, e;
ll na, ma, nb, mb;
ll br[sz], ar[sz], mn[sz], mx[sz], used[sz];
char g[123][123];
string s[sz], t, ress;
vector < ll > vec, as;
map < ll, ll> mmap;
set <ll> ss;
bool ok, oka[sz];
char ch;
map<pair<int, int>, int>    mpp;

ll bpow(ll v, ll u, ll mod){
    if(!u) return 1;
    ll res = bpow(v, u / 2, mod);
    res = (res * 1ll * res) % mod;
    if(u & 1) res = (res * 1ll * v) % mod;
    return res;
}

ll gcd(ll a, ll b){
    if(a > b) swap(a, b);
    if(!a)    return b;
    return gcd(b % a, a);
}

void dii(){
    cin >> n >> b;
    for(int i = 1;i < n; i++){
        cin >> a;
        if((i % 2 == 0 && (n - b + a) % n != i) || (i % 2 != 0 && (b + a) % n != i)){
            cout << "NO";
            return;
        }
    }
    cout<<"YES";
}
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q = 1;
    //cin >> q;
    while(q--) dii();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;cin>>n;
    int arr[n];

    for(auto &i:arr)
        cin>>i;

    int x;
    if(arr[0] == 0)
        x = 0;
    else
        x = n - arr[0];

    for(int i=1;i<n;i++)
    {
        if(i & 1)
        {
            int y = (arr[i]-x);
            y += n;
            y %= n;
            if(y != i)
            {
                cout<<"No";
                return 0;
            }
        }
        else
        {
            int y = (arr[i] + x)%n;
            if(y != i)
            {
                cout<<"NO";
                return 0;
            }
        }
    }

    cout<<"Yes";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define speedio ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v)	((v).begin()), ((v).end())
#define sz(v)	((int)((v).size()))
#define reset(i,n) memset(i, n, sizeof(i))
#define set_bit(n,i) (n|=(1<<i))
#define get_bit(n,i) ((n >> i) &1)
#define fin(f) freopen((f),"r",stdin)
#define fout(f) freopen((f),"w",stdout)
int dx[8] = { 0, 0, 1, 1, 1,-1,-1,-1 };
int dy[8] = { 1,-1, 0,-1, 1, 1, 0,-1 };

typedef long long ll;
typedef long double ld;

int main()
{
    speedio;
    int n;
    cin>>n;
    vector<int>v(n),v2(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        v2[i]=v[i];
        if(i&1)v2[i]=n-1-v2[i];
    }
    for(int i=0;i<n;i++){
        int fake=0;
        for(int k=1;k<n;k++)if(v[k]-v[k-1]!=1)fake=1;
        if(!fake)return!(cout<<"YES");
        for(int j=0;j<n;j++){
            v2[j]++;
            if(j&1)v[j]=(-v2[j]%n+n-1);
            else v[j]=v2[j]%n;
        }
    }
    cout<<"NO";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define speedio ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v)	((v).begin()), ((v).end())
#define sz(v)	((int)((v).size()))
#define reset(i,n) memset(i, n, sizeof(i))
#define set_bit(n,i) (n|=(1<<i))
#define get_bit(n,i) ((n >> i) &1)
#define fin(f) freopen((f),"r",stdin)
#define fout(f) freopen((f),"w",stdout)
int dx[8] = { 0, 0, 1, 1, 1,-1,-1,-1 };
int dy[8] = { 1,-1, 0,-1, 1, 1, 0,-1 };

typedef long long ll;
typedef long double ld;

int main()
{
    speedio;
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    int dif=n-v[0];
    for(int i=1;i<n;i++){
        if(i&1&&-(n-v[i]+dif)%n+n!=i)return!(cout<<"NO");
        else if(!(i&1)&&(v[i]+dif)%n!=i)return!(cout<<"NO");
    }
    cout<<"YES";
    return 0;
}


	#include<iostream>
	#include<algorithm>
	#include<vector>
	#include<map>
	#include<string>
	#include<fstream>
	#define ll long long
	using namespace std;

	bool bs(int arr[],int n)
	{

		for (int i = n / 2; i < n-1; ++i) {
			for (int j = i + 1; j < n; ++j) {
				if (arr[i] > arr[j]) {
					return 0;
				}
			}

		}
		return 1;
	}

int bt(int n)
	{
		if (n == 0)return 0;
		if (n == 4 || n == 7)return 1;
		string num = to_string(n);
		static int cnt = 0;
		int sz = 0;
		if (num.find_first_of("74") + 1) {
			for (int i = 0; i < num.size(); ++i) {
				if (num[i] == '4' || num[i] == '7') {
					sz++;
				}
				else break;
			}
		}
		bt(n - 1);

		if (sz == num.size())
			 cnt++;

		return cnt;
	}

int perm(int n, int r)
{
	int total = 1;
	for (int j = 1; j <= n; ++j) {
		total *= j;
		for (int k = j; k <= n - r; ++k) {
			total /= k;
			break;
		}
	}

	return total;
}

	int main()
	{
		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
		int n; cin >> n;
		int *gear = new int[n];
		for (int i = 0; i < n; ++i)cin >> gear[i];
		int num = gear[0];
		do {
			for (int i = 0; i < n; ++i) {
				if (i % 2 == 0) {
					if (gear[i] == n - 1)gear[i] = 0;
					else gear[i]++;
				}
				else {
					if (gear[i] == 0)gear[i] = n - 1;
					else gear[i]--;
				}
				}

			if (bs(gear, n) && gear[0] == 0 && gear[n - 1] == n - 1) {
				cout << "Yes\n";
				return 0;
			}
		} while (gear[0] != num);

		cout << "No\n";
		return 0;
	}


	#include<iostream>
	#include<algorithm>
	#include<vector>
	#include<map>
	#include<string>
	#include<fstream>
	#define ll long long
	using namespace std;

	bool bs(int arr[],int n)
	{

		for (int i = n / 2; i < n-1; ++i) {
			for (int j = i + 1; j < n; ++j) {
				if (arr[i] > arr[j]) {
					return 0;
				}
			}

		}
		return 1;
	}

int bt(int n)
	{
		if (n == 0)return 0;
		if (n == 4 || n == 7)return 1;
		string num = to_string(n);
		static int cnt = 0;
		int sz = 0;
		if (num.find_first_of("74") + 1) {
			for (int i = 0; i < num.size(); ++i) {
				if (num[i] == '4' || num[i] == '7') {
					sz++;
				}
				else break;
			}
		}
		bt(n - 1);

		if (sz == num.size())
			 cnt++;

		return cnt;
	}

int perm(int n, int r)
{
	int total = 1;
	for (int j = 1; j <= n; ++j) {
		total *= j;
		for (int k = j; k <= n - r; ++k) {
			total /= k;
			break;
		}
	}

	return total;
}

	int main()
	{
		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
		int n; cin >> n;
		int *gear = new int[n];
		for (int i = 0; i < n; ++i)cin >> gear[i];
		int num = gear[0];
		do {
			for (int i = 0; i < n; ++i) {
				if (i % 2 == 0) {
					if (gear[i] == n - 1)gear[i] = 0;
					else gear[i]++;
					if (gear[0] == num)break;
				}
				else {
					if (gear[i] == 0)gear[i] = n - 1;
					else gear[i]--;
				}
				}

			if ( gear[0] == 0 && gear[n - 1] == n - 1 && bs(gear, n)) {
				cout << "Yes\n";
				return 0;
			}
		} while (gear[0] != num);

		cout << "No\n";
		return 0;
	}


	#include<iostream>
	#include<algorithm>
	#include<vector>
	#include<map>
	#include<string>
	#include<fstream>
	#define ll long long
	using namespace std;

	bool bs(int arr[],int n)
	{

		for (int i = n / 2; i < n-1; ++i) {
			for (int j = i + 1; j < n; ++j) {
				if (arr[i] > arr[j]) {
					return 0;
				}
			}

		}
		return 1;
	}

int bt(int n)
	{
		if (n == 0)return 0;
		if (n == 4 || n == 7)return 1;
		string num = to_string(n);
		static int cnt = 0;
		int sz = 0;
		if (num.find_first_of("74") + 1) {
			for (int i = 0; i < num.size(); ++i) {
				if (num[i] == '4' || num[i] == '7') {
					sz++;
				}
				else break;
			}
		}
		bt(n - 1);

		if (sz == num.size())
			 cnt++;

		return cnt;
	}

int perm(int n, int r)
{
	int total = 1;
	for (int j = 1; j <= n; ++j) {
		total *= j;
		for (int k = j; k <= n - r; ++k) {
			total /= k;
			break;
		}
	}

	return total;
}

	int main()
	{
		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
		int n; cin >> n;
		int *gear = new int[n];
		for (int i = 0; i < n; ++i)cin >> gear[i];
		int num = gear[0];
		do {
			for (int i = 0; i < n; ++i) {
				if (i % 2 == 0) {
					if (gear[i] == n - 1)gear[i] = 0;
					else gear[i]++;

				}
				else {
					if (gear[i] == 0)gear[i] = n - 1;
					else gear[i]--;
				}
				}

			if ( gear[0] == 0 && gear[n - 1] == n - 1 && bs(gear, n)&&(gear[0]!=gear[1]&&(gear[n-1]!=gear[n-2]))) {
				cout << "Yes\n";
				return 0;
			}

		} while (gear[0] != num);

		cout << "No\n";
		return 0;
	}


#include<bits/stdc++.h>
using namespace std;
/*** Typedef ***/
typedef long long ll;
typedef unsigned long long ull;
/*** Input Output ***/
// #define sci1(a) scanf("%d",&a)
// #define sci2(a,b) scanf("%d %d",&a,&b)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)
#define sc3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfi1(a) printf("%d\n",a)
#define pfi2(a,b) printf("%d %d\n",a,b)
#define pf1(a) printf("%lld\n",a)
#define pf2(a,b) printf("%lld %lld\n",a,b)
/*** Loops ***/
#define for0(num) for(ll i = 0; i < num; i++)
#define for1(num) for(ll i = 1; i <= num; i++)
#define forev(num) for(ll i = num - 1; i > 0; i--)
#define forin(arr, num) for(ll i = 0; i < num; i++) sc1(arr[i]);
#define forin1(arr, num) for(ll i = 1; i <= num; i++) sc1(arr[i]);
/*** Define Values ***/
#define mx 200005
#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-7
#define size1 100005
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
const double pi=3.14159265358979323846264;

#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mem(name, value) memset(name, value, sizeof(name))
/*** STLs ***/
typedef vector <ll> vll;
typedef set <ll, greater<ll> > sll;
typedef multiset <ll> msll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll , ll> > vpll;
/*** Sorts ***/
#define all(v) ((v).begin(), (v).end())
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtGreat(v) sort(all(v), greater<ll>())
inline bool cmp(pll a,pll b){ if(a.ff == b.ff)return a.ss < b.ss; return a.ff > b.ff; }
/***euler GCD***/
template <class T> inline T gcd(T a,T b){if(b == 0)return a; return gcd(b, a % b);}
/***LCM***/
template <class T> inline T lcm(T a,T b){return a * b / gcd<T>(a, b);}
/***binary exponentiation***/
int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
/*** Some Prints ***/
#define no cout << "NO" << '\n'
#define yes cout << "YES" << '\n'
#define case cout << "Case " << t++ << ": "
int main()
{
	ll n,m,tc;
	sc1(tc);
	while(tc--)
	{
	    sc1(n);
	    ll a[n];
	    for0(n)
	        sc1(a[i]);
	    for(int i=0;i<n;i++)
	    {
	        bool f=true;
	        for(int j=0;j<n;j++)
	        if(a[j]!=j)
	            f=false;
	        if(f)
	        {
	            yes;
	            return 0;
	        }
	        for (int j = 0; j < n; j++)
            {
                if (j % 2 == 0)
                    a[j] = (a[j] + 1) % n;
                else
                    a[j] = (a[j] + n - 1) % n;
            }
	    }
	    no;
	}
}


#include<bits/stdc++.h>
using namespace std;
/*** Typedef ***/
typedef long long ll;
typedef unsigned long long ull;
/*** Input Output ***/
// #define sci1(a) scanf("%d",&a)
// #define sci2(a,b) scanf("%d %d",&a,&b)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)
#define sc3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfi1(a) printf("%d\n",a)
#define pfi2(a,b) printf("%d %d\n",a,b)
#define pf1(a) printf("%lld\n",a)
#define pf2(a,b) printf("%lld %lld\n",a,b)
/*** Loops ***/
#define for0(num) for(ll i = 0; i < num; i++)
#define for1(num) for(ll i = 1; i <= num; i++)
#define forev(num) for(ll i = num - 1; i > 0; i--)
#define forin(arr, num) for(ll i = 0; i < num; i++) sc1(arr[i]);
#define forin1(arr, num) for(ll i = 1; i <= num; i++) sc1(arr[i]);
/*** Define Values ***/
#define mx 200005
#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-7
#define size1 100005
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
const double pi=3.14159265358979323846264;

#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mem(name, value) memset(name, value, sizeof(name))
/*** STLs ***/
typedef vector <ll> vll;
typedef set <ll, greater<ll> > sll;
typedef multiset <ll> msll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll , ll> > vpll;
/*** Sorts ***/
#define all(v) ((v).begin(), (v).end())
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtGreat(v) sort(all(v), greater<ll>())
inline bool cmp(pll a,pll b){ if(a.ff == b.ff)return a.ss < b.ss; return a.ff > b.ff; }
/***euler GCD***/
template <class T> inline T gcd(T a,T b){if(b == 0)return a; return gcd(b, a % b);}
/***LCM***/
template <class T> inline T lcm(T a,T b){return a * b / gcd<T>(a, b);}
/***binary exponentiation***/
int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
/*** Some Prints ***/
#define no cout << "NO" << '\n'
#define yes cout << "YES" << '\n'
#define case cout << "Case " << t++ << ": "
int main()
{
	ll n,m,tc;
// 	sc1(tc);
// 	while(tc--)
// 	{
	    sc1(n);
	    ll a[n];
	    for0(n)
	        sc1(a[i]);
	    for(int i=0;i<n;i++)
	    {
	        bool f=true;
	        for(int j=0;j<n;j++)
	        if(a[j]!=j)
	            f=false;
	        if(f)
	        {
	            yes;
	            return 0;
	        }
	        for (int j = 0; j < n; j++)
            {
                if (j % 2 == 0)
                    a[j] = (a[j] + 1) % n;
                else
                    a[j] = (a[j] + n - 1) % n;
            }
	    }
	    no;
// 	}
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');
    cout.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

int main(){
    nimble;
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,n)
        cin>>a[i];
    int req=(n-a[0])%n;
    rep(i,1,n){
        int x=i;
        x=(a[i]+req)%n;
        if(i&1)
            x=(n+a[i]-req)%n;
        if(x!=i)
            return cout<<"No",0;
    }
    cout<<"Yes";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long q[1234567], r[1234567], qr[1234][1234];
#define SZ size()
#define S string
#define LL long long
#define stop exit(0)
#define gcd(a,b) for(LL gcd=min(a,b); gcd>=1; gcd--){if(a%gcd==0&&b%gcd==0){break;}}
#define c(a) cout<<a;
//freopen("input.txt", "r", stdin)freopen("outp ut.txt", "w", stdout)
//char ggg = *max_element(s.begin(), s.end());f=count(s.begin(), s.end(), ggg);
int main (){
    double bb, cc, dd, ee, ff, gg=0;
    S m[1234567], n="", o, s, ss, nn, oo, mm[1234567];
    map<S, LL> aa;
    LL a,b,c,d=0,e=0,f=0,g=0,i,j,k,l=1,r[300001],n[300001],m[300001],z[400001],h[600001],p[600001];
    string s,t,x,y;
    dd q,u,w;
    cin>>a;
    for(i=1;i<=a;i++){
        cin>>p[i];
        h[i]=i-1;
    }
    for(i=1;i<=a;i++){
        for(j=1;j<=a;j++){
            if(j%2==1){
                h[j]--;
                if(h[j]==-1){
                    h[j]=a-1;
                }
            }
            else{
                h[j]++;
                if(h[j]==a){
                    h[j]=0;
                }
            }
            if(p[j]==h[j]){
                d++;
            }
        }
        if(d>0&&d!=a){
            cout<<"No";
            stop;
        }
        if(d==a){
            cout<<"Yes";
            stop;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
long long q[1234567], r[1234567], qr[1234][1234];
#define SZ size()
#define S string
#define LL long long
#define stop exit(0)
#define gcd(a,b) for(LL gcd=min(a,b); gcd>=1; gcd--){if(a%gcd==0&&b%gcd==0){break;}}
#define c(a) cout<<a;
//freopen("input.txt", "r", stdin)freopen("outp ut.txt", "w", stdout)
//char ggg = *max_element(s.begin(), s.end());f=count(s.begin(), s.end(), ggg);
int main (){
    double bb, cc, dd, ee, ff, gg=0;
    map<S, LL> aa;
    LL a,b,c,d=0,e=0,f=0,g=0,i,j,k,l=1,r[300001],n[300001],m[300001],z[400001],h[600001],p[600001];
    cin>>a;
    for(i=1;i<=a;i++){
        cin>>p[i];
        h[i]=i-1;
    }
    for(i=1;i<=a;i++){
        for(j=1;j<=a;j++){
            if(j%2==1){
                h[j]--;
                if(h[j]==-1){
                    h[j]=a-1;
                }
            }
            else{
                h[j]++;
                if(h[j]==a){
                    h[j]=0;
                }
            }
            if(p[j]==h[j]){
                d++;
            }
        }
        if(d>0&&d!=a){
            cout<<"No";
            stop;
        }
        if(d==a){
            cout<<"Yes";
            stop;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

bool chk(int * arr, int  n){

	for(int i = 0; i < n; i++){
		if(i != arr[i]) return false;
	}
	return true;

}

int main(){

	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}

	int flag = 0;
	for(int j = 0; j < n ; j++){

		for(int i = 0; i < n ; i++){
			if(i & 1){
				if(!arr[i]){
					arr[i] = n - 1;
				}else{
					arr[i]--;
				}
			}else{
				if(arr[i] == n - 1){
					arr[i]  = 0;
				}else{
					arr[i]++;
				}
			}
		}
		if(chk(arr, n)){
			flag = 1;
			break;
		}
		// for(auto x : arr) cout << x << " ";
		// 	cout << endl;
	}
	if(flag) cout << "YES";
	else cout << "NO";
}


#include <bits/stdc++.h>

#define MOD (1000000007)
#define EPS (1e-9)
#define INF (2117117117)
#define LLINF (2117117117117117117LL)
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define sqr(a) ((a) * (a))
#define sz(a) ((int) (a).size())
const double PI = acos(-1.0);

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef unsigned int uint;
typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

#define TASK "task"

using namespace std;

int n, a, rot;

int main()
{
#ifdef lordf
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen(TASK".in", "r", stdin);
    //freopen(TASK".out", "w", stdout);
#endif

    scanf("%d %d", &n, &a);
    rot = n - a;
    for (int i = 1; i < n; i++)
    {
        scanf("%d", &a);
        (a += ((i & 1) ? n - rot : rot)) %= n;
        if (a != i)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2000;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    int a[MAXN];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        bool f = true;
        for (int j = 0; j < n; j++)
            if (a[j] != j)
                f = false;
        if (f)
        {
            cout << "Yes\n";
            return 0;
        }
        for (int j = 0; j < n; j++)
        {
            if (j % 2 == 0)
                a[j] = (a[j] + 1) % n;
            else
                a[j] = (a[j] + n - 1) % n;
        }
    }
    cout << "No\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){

	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	ll su = 0;
	for(int i = 1; i < n; i++){
		su += arr[i];
	}
	if(n&1 && su%2 == 0){
		cout << "YES";
	}else if(n % 2== 0 && su & 1){
		cout << "YES";
	}else cout << "NO";

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int ,int> pairs;
int main()
{
    int n,weight,value=0,a=0,b=0,t,x,y,w,l=0,trump,cost=0;
  string s;
  int arra[100];
  bool flag=true;
  char c;
  cin>>t;
for(int j=0;j<t;j++)
{
    cin>>arra[j];

}
if(arra[0]!=0){
a=t-arra[0];}

for(int i=1;i<t;i++)
{
    if(i%2==1)
    {
        b=arra[i]-a;
        if(!(b==i||b==(i-t)))
        {
            cout<<"NO"<<endl;
            flag=false;
            break;
        }
    }
    else
    {
        b=arra[i]+a;
        if(!(b==i||b==(t+i)))
        {
            cout<<"NO"<<endl;
            flag=false;
            break;
        }
    }
}
if(flag)
    cout<<"YES"<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int ,int> pairs;
int main()
{
    int n,weight,value=0,a=0,b=0,t,x,y,w,l=0,trump,cost=0;
  string s;
  int arra[100];
  bool flag=true;
  char c;
  cin>>t>>x;
if(x!=0){
a=t-x;}

for(int i=1;i<t;i++)
{
    cin>>x;
    if(i%2==1)
    {
        b=x-a;
        if(!(b==i||b==(i-t)))
        {
            cout<<"NO"<<endl;
            flag=false;
            break;
        }
    }
    else
    {
        b=x+a;
        if(!(b==i||b==(t+i)))
        {
            cout<<"NO"<<endl;
            flag=false;
            break;
        }
    }
}
if(flag)
    cout<<"YES"<<endl;

}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool checkIfWorks(int number, int maxNumber, int amountOfTurns,int currentMove, int currentNumberCheck){
    if(currentMove == 1){
        for(int i = 0; i < amountOfTurns;i++){
            if(number + 1 == maxNumber){
                number = 0;
            }else{
                number++;
            }
        }
    }else{
        for(int i = 0; i < amountOfTurns;i++){
            if(number - 1 < 0){
                number = maxNumber-1;
            }else{
                number--;
            }
        }
    }
    if(number == currentNumberCheck){
        return 1;
    }else{
        return 0;
    }
}
int main() {
    int n; cin >> n;
    vector<int> numbers;
    for(int i = 0; i < n; i++){
        int num; cin >> num;
        numbers.push_back(num);
    }
    int amountOfTurns = 0;
    int dummy = numbers[0];
    while(dummy != 0){
        amountOfTurns++;
        if(dummy + 1 == n){
            dummy = 0;
        }else{
            dummy++;
        }
    }
    int currentNumber = 0;
    int currMove = 1;
    for(int i = 0; i < numbers.size();i++){
        if(checkIfWorks(numbers[i], n, amountOfTurns, currMove, currentNumber)){
            currentNumber++;
            if(currMove == 1){
                currMove++;
            }else{
                currMove--;
            }
        }else{
            break;
        }
    }
    if(currentNumber == n){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int checkCorrect(int number, int currentMove, int maxNumber, int currNum, int n){
    if(currentMove == 1){
        for(int i =0; i < maxNumber; i++){
            if(number + 1 == n){
                number = 0;
            }else{
                number++;
            }
        }
    }else{
        for(int i =0; i < maxNumber; i++){
            if(number - 1 < 0){
                number = maxNumber-1;
            }else{
                number--;
            }
        }
    }
    if(number == currNum){
        return 1;
    }else{
        return 0;
    }
}
int main() {
    int n; cin >> n;
    vector<int> nums;
    for(int i = 0; i < n; i++){
        int num; cin >> num;
        nums.push_back(num);
    }
    int currNum = 0;
    int currentMove = 1;
    int amountOfTurns = 0;
    int numberToCheck = nums[0];
    while(numberToCheck != 0){
        amountOfTurns++;
            if(numberToCheck + 1 == n){
                numberToCheck = 0;
            }else{
                numberToCheck++;
            }
    }
        for(int i = 0; i < n;i++){
        if(checkCorrect(nums[0], currentMove, amountOfTurns, currNum, n)){
            currNum++;
            if(currentMove == 1){
                currentMove++;
            }else{
                currentMove--;
            }
        }else{
            break;
        }
    }
        if(currNum == n-1){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int x,i,j,f,c,p;

    cin>>x;

    int n[x];

    for(i=0;i<x;i++)
        cin>>n[i];

    for(i=0;i<=x;i++)
    {
        c=0;
        for(j=0;j<x;j++)
        {
            if(n[j]==j) c++;
            else break;
        }

        if(c==x) { cout<< "YES\n"; return 0; }

        for(j=0;j<x;j++)
        {
            if(j%2==0) n[j]++;
            else n[j]--;

            if(n[j]==x) n[j]=0;
            else if(n[j]==-1) n[j]=x-1;
        }
    }

    cout<< "NO\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
bool check(vector<int> &v) {
    for (int i = 0; i < n; i++)
        if (v[i] != i)
            return false;
    return true;
}

int main() {
    cin >> n; vector<int> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];

    if (check(v)) {
        cout << "YES" << endl;
        return 0;
    }

    for (int i = 0; i < 1001; i++) {
        for (int j = 0; j < n; j++) {
            if (j % 2 == 0)
                v[j] = (v[j] + 1) % n;
            else
                v[j] = (v[j] - 1 + n) % n;
        }

        if (check(v)) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;

}


/* ****Yash_mittal**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define bell        1000000009
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    set<int> s;
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            if(i-arr[i]>=0)
                s.insert(i-arr[i]);
            else
            {
                s.insert(i-arr[i]+n);
            }
        }
        else
        {
            if(i-arr[i]>0)
                s.insert(n-(i-arr[i]));
            else
                s.insert(arr[i]-i);
        }
    }
    if(s.size()==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	for(int j=0; j<n && a[0]!=0; j++){
		for(int i=0; i<n; i++){
			if(i%2 == 0 || i==0) a[i]++;
			else a[i]--;
			if(a[i] == n) a[i] = 0;
			if(a[i] == -1) a[i] = n-1;
		}
	}
	bool ys = true;
	for(int i=0; i<n-1; i++){
		if(a[i]+1 != a[i+1]){
			ys = false;
			break;
		}
	}
	//for(int i=0; i<n; i++) cout << a[i] << " ";

	cout << (ys ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int a[n];
	bool check = true;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	int ss = n-a[0];
	for(int i=1; i<n; i++){
		int tt;
		if(i%2==1){
			tt = a[i]-ss;
			if(tt<0) tt = n+tt;
			if(tt!=i) check = false;
		}
		else{
			tt = a[i]+ss;
			if(tt>n-1) tt = tt+1-n;
			if(tt != i) check = false;
		}
		if(check==false) break;
	}
	if(check) cout << "YES";
	else cout << "NO";
	//cout << ss;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        bool f = true;
        for (int j = 0; j < n; j++)
            if (a[j] != j)
                f = false;
        if (f)
        {
            cout << "Yes\n";
            return 0;
        }
        for (int j = 0; j < n; j++)
        {
            if (j % 2 == 0)
                a[j] = (a[j] + 1) % n;
            else
                a[j] = (a[j] + n - 1) % n;
        }
    }
    cout << "No\n";
}


#include<bits/stdc++.h>
using namespace std;
int n,a;
set<int>s;
string sequence(int n){
    for(int i=0;i<n;i++){
        cin>>a;
        if(i%2==0){
            if(i<=a)s.insert(n-a+i);
            else s.insert(i-a);
        }
        else{
            if(i>=a)s.insert(a+n-i);
            else s.insert(a-i);
        }
    }
    return s.size()==1?"YES":"NO";
}
int main(){
    cin>>n;cout<<sequence(n);
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define forn(i,n) for(int i=0;i<(int)n;i++)
#define rev(i,n) for(int i=(int)n-1;i>=0;i--)
#define fore(i,n) for(int i=1;i<=(int)n;i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define rmii            map<int,int,greater<int>>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

void fun(int *a, int n)
{
    for(int i=0;i<n;i++)
    {
        if(i%2 == 0)
        {
            a[i] = (a[i] + 1)%n;
        }
        else
        {
            a[i] = (a[i] - 1)%n;

            if(a[i] < 0)
                a[i] = n + a[i];
        }
    }

}
int main()
{
    int n;
    cin>>n;

    int a[n];

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

    while(a[0] != 0)
        fun(a, n);

    bool flag = true;
     int i = 0;

    while(flag)
    {

        if(a[i] != i)
        {
            flag = false;
            cout<<"No"<<endl;
            return 0;
        }
        if(i == n-1)
            break;
        i++;
    }
    cout<<"Yes"<<endl;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define forn(i,n) for(int i=0;i<(int)n;i++)
#define rev(i,n) for(int i=(int)n-1;i>=0;i--)
#define fore(i,n) for(int i=1;i<=(int)n;i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define rmii            map<int,int,greater<int>>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

void fun(int *a, int n)
{
    for(int i=0;i<n;i++)
    {
        if(i%2 == 0)
        {
            a[i] = (a[i] + 1)%n;
        }
        else
        {
            a[i] = (a[i] - 1)%n;

            if(a[i] < 0)
                a[i] = n + a[i];
        }
    }

}
int main()
{
    int n;
    cin>>n;

    int a[n];

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

    while(a[0] != 0)
        fun(a, n);

    bool flag = true;
     int i = 0;

    while(flag)
    {

        if(a[i] != i)
        {
            flag = false;
            cout<<"No"<<endl;
            return 0;
        }
        if(i == n-1)
            break;
        i++;
    }
    cout<<"Yes"<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define forn(i,n) for(int i=0;i<(int)n;i++)
#define rev(i,n) for(int i=(int)n-1;i>=0;i--)
#define fore(i,n) for(int i=1;i<=(int)n;i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define rmii            map<int,int,greater<int>>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

bool checksort(int size, int a[])
{   int n=size;
    bool flag=false;
    for(int i=0;i<n-1;i++)
      {
        //   cout<<a[i]<<" "<<a[i+1]<<endl;

          if(a[i]<a[i+1])
            flag=true;
          else
            flag=false;

      }
    //   cout<<"flag is "<<flag<<endl;
      return flag;
}

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

        int n;
        cin>>n;

        int a[n];
        forn(i,n)
        {
            cin>>a[i];
        }

        if(checksort(n,a))
        {
            cout<<"Yes"<<endl;
            return 0;
        }

        bool sorted=false;
        for(int i=0;i<=n;i++)
        {
            if(i%2 != 0 )
            {
                if(a[i]==n-1)
                    a[i]=0;

                else
                    a[i]+=1;
            }

            else
            {
                if(a[i]==0)
                    a[i]=n-1;

                else
                    a[i]-=1;
            }

            if(checksort(n,a))
                {sorted=true;
                break;}
            else
                continue;
        }

        if(sorted)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define forn(i,n) for(int i=0;i<(int)n;i++)
#define rev(i,n) for(int i=(int)n-1;i>=0;i--)
#define fore(i,n) for(int i=1;i<=(int)n;i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define rmii            map<int,int,greater<int>>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

void fun(int *a, int n)
{
    for(int i=0;i<n;i++)
    {
        if(i%2 == 0)
        {
            a[i] = (a[i] + 1)%n;
        }
        else
        {
            a[i] = (a[i] - 1)%n;

            if(a[i] < 0)
                a[i] = n + a[i];
        }
    }

}

int32_t main()
{
    int n;
    cin>>n;

    int a[n];

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

    while(a[0] != 0)
        fun(a, n);

    bool flag = true;
     int i = 0;

    while(flag)
    {

        if(a[i] != i)
        {
            flag = false;
            cout<<"No"<<endl;
            return 0;
        }
        if(i == n-1)
            break;
        i++;
    }
    cout<<"Yes"<<endl;

    return 0;
}


#include <iostream>
#include <bits/stdtr1c++.h>
using namespace std;
#define ll  long long
#define ld long double
#define pb push_back
#define INF 0x3f3f3f3f
//#define for(i,n) for(int i = 0 ; i < n ; i++)
#define vi vector<int>
#define vl vector<long long>
#define print(el) cout<<(el)<<endl;
//    freopen ("input.txt", "r", stdin);
//    freopen ("output.txt", "w", stdout);

const int N = int(1e5 + 3);
const long double PI = 3.1415926536;
ll a[int(1e6)];
ll b[int(1e6)];
//vector<ll> vis;
int main()
{
ll n;
cin>>n;
int cnt = 0;

for(int i=0 ; i<n ; i++)
{
    cin>>a[i];
}

while (cnt<n)
{
    bool flag = true;
    for(int i=0 ; i<n ; i++)
    {
        if(i%2==0) // clockwise
        {
            a[i] = (a[i]+1)%n;

        }
        else
        {
           a[i] = (a[i]+n-1)%n;
        }
    }
    for(int i=0 ; i<n ; i++)
    {
        if(a[i]!=i)
        {
            flag = false;
        }
    }

if(flag)
   {
       cout<<"Yes";
       exit(0);
   }
    cnt++;
}
    cout<<"No";
}


#include <iostream>
#include <bits/stdtr1c++.h>
using namespace std;
#define ll  long long
#define ld long double
#define pb push_back
#define INF 0x3f3f3f3f
//#define for(i,n) for(int i = 0 ; i < n ; i++)
#define vi vector<int>
#define vl vector<long long>
#define print(el) cout<<(el)<<endl;
//    freopen ("input.txt", "r", stdin);
//    freopen ("output.txt", "w", stdout);

const int N = int(1e5 + 3);
const long double PI = 3.1415926536;
ll a[int(1e6)];
ll b[int(1e6)];
//vector<ll> vis;
int main()
{
ll n;
cin>>n;
int cnt = 0;

for(int i=0 ; i<n ; i++)
{
    cin>>a[i];
}

while (cnt<n)
{
    bool flag = true;
    for(int i=0 ; i<n ; i++)
    {
        if(i%2==0) // clockwise
        {
            if(a[i]<n-1)
                a[i]++;
            else if(a[i]==n-1)
                a[i]=0;
        }
        else if( i%2 !=0)
        {
            if(a[i]!=0)
                a[i]--;
            else if (a[i]==0)
                a[i]=n-1;
        }
    }
    for(int i=0 ; i<n ; i++)
    {
        if(a[i]!=i)
        {
            flag = false;
        }
    }

if(flag)
   {
       cout<<"Yes";
       exit(0);
   }
    cnt++;
}
    cout<<"No";
}


#include<bits/stdc++.h>

using namespace std;
using   ll = long long;

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

#define int             long long int

#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second

#define pii             pair<int , int>
#define vec 			vector< int >

#define ALL(v)          v.begin(),v.end()
#define ALLR(v)         v.rbegin(),v.rend()
#define pi              3.14159265358979323
#define inf             LLONG_MAX
#define ones(x)         __builtin_popcount(x)
#define fill(a,b)       memset(a,b,sizeof(a))
#define mod             1000000007

int mod_pow(int a,int b,int m)
{
    int res = 1;
    while(b)
    {
        if(b&1)
        {
            res = (res*a) % m;
        }
        a = (a*a) % m;
        b >>= 1;
    }
    return res;
}

int mod_inverse(int a , int m)
{
    return mod_pow(a , m - 2 , m);
}

void solve() {
	int n;

	cin >> n;

	int a[n];
	int b[n];

	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		b[i] = i;
	}

	for(int i = 0; i <= n; ++i) {
		for(int j = 0; j < n; ++j) {
			if(j % 2 == 0) {
				a[j]++;
				a[j] %= n;
			}
			else {
				a[j]--;
				a[j] += n;
				a[j] %= n;
			}
		}

		int ok = 1;

		for(int j = 0; j < n; ++j) {
			if(b[j] != a[j]) {
				ok = 0;
			}
		}

		if(ok) {
			cout << "Yes";
			return;
		}
	}

	cout << "No";
}

signed main() {
    fast;

    int t = 1;

    //cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename X> inline X sqr(const X& a) { return a * a; }

#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define file_name(a) (freopen(((string)(a) + ".in").c_str(),"r",stdin), freopen(((string)(a) + ".out").c_str(),"w",stdout))
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair <int, int>

int nxt() {
	int x;
	cin >> x;
	return x;
}

int main() {
	int n = nxt();
	vector <int> a(n);
	generate(all(a), nxt);
	forn(t, n) {
		forn(i, n) {
			if (i % 2 == 0) {
				a[i] = (a[i] + 1) % n;
			}
			else {
				a[i] = (a[i] - 1 + n) % n;
			}
		}
		bool b = true;
		forn(i, n) {
			b &= a[i] == i;
		}
		if (b) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename X> inline X sqr(const X& a) { return a * a; }

#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define file_name(a) (freopen(((string)(a) + ".in").c_str(),"r",stdin), freopen(((string)(a) + ".out").c_str(),"w",stdout))
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair <int, int>

int nxt() {
	int x;
	cin >> x;
	return x;
}

int main() {
	int n = nxt();
	vector <int> a(n);
	generate(all(a), nxt);
	forn(t, n) {
		forn(i, n) {
			if (i % 2 == 0) {
				a[i] = (a[i] + 1) % n;
			}
			else {
				a[i] = (a[i] - 1 + n) % n;
			}
		}
		bool f = true;
		forn(i, n) {
			f &= a[i] == i;
		}
		if (f) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename X> inline X sqr(const X& a) { return a * a; }

#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define file_name(a) (freopen(((string)(a) + ".in").c_str(),"r",stdin), freopen(((string)(a) + ".out").c_str(),"w",stdout))
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair <int, int>

int nxt() {
	int x;
	cin >> x;
	return x;
}

int main() {
	int n = nxt();
	vector <int> a(n);
	generate(all(a), nxt);
	forn(t, n - 2) {
		forn(i, n) {
			if (i % 2 == 0) {
				a[i] = (a[i] + 1) % n;
			}
			else {
				a[i] = (a[i] - 1 + n) % n;
			}
		}
		bool f = true;
		forn(i, n) {
			f &= a[i] == i;
		}
		if (f) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename X> inline X sqr(const X& a) { return a * a; }

#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define file_name(a) (freopen(((string)(a) + ".in").c_str(),"r",stdin), freopen(((string)(a) + ".out").c_str(),"w",stdout))
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair <int, int>

int nxt() {
	int x;
	cin >> x;
	return x;
}

int main() {
	int n = nxt();
	vector <int> a(n);
	generate(all(a), nxt);
	forn(t, n - 2) {
		forn(i, n) {
			if (i % 2 == 0) {
				a[i] = (a[i] + 1) % n;
			}
			else {
				a[i] = (a[i] - 1 + n) % n;
			}
		}
		bool b = true;
		forn(i, n) {
			b &= a[i] == i;
		}
		if (b) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename X> inline X sqr(const X& a) { return a * a; }

#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define file_name(a) (freopen(((string)(a) + ".in").c_str(),"r",stdin), freopen(((string)(a) + ".out").c_str(),"w",stdout))
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair <int, int>

int nxt() {
	int x;
	cin >> x;
	return x;
}

int main() {
	int n = nxt();
	vector <int> a(n);
	generate(all(a), nxt);
	forn(t, n - 1) {
		forn(i, n) {
			if (i % 2 == 0) {
				a[i] = (a[i] + 1) % n;
			}
			else {
				a[i] = (a[i] - 1 + n) % n;
			}
		}
		bool b = true;
		forn(i, n) {
			b &= a[i] == i;
		}
		if (b) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}


#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 all(x)          x.begin(), x.end()
#define sz(x)           (int)x.size()
#define pb              push_back

#define ll              long long
#define int             long long

template <typename T>
using ordered_set = tree<T, null_type,
      less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

const int MOD1 = 1000000007;
const int MOD2 = 998244353;
const double PI = acos((double) - 1);
const int N = 1e5 + 10;

void solve() {
	int n;
	cin >> n;
	int ans;
	cin >> ans;
	for (int i = 1; i < n; ++i) {
		int a;
		cin >> a;
		if (i & 1) {
			a = (n - a + i) % n;
		} else {
			a = (a - i + n) % n;
		}
		if (a != ans) {
			cout << "No";
			return;
		}
	}
	cout << "Yes";
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
		cout << '\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>	//v(n, 0)
#define ep emplace_back
#define pb push_back
#define ff first
#define ss second
#define db(x) cout << #x << " " << x << endl;
ll gcd(ll a, ll b){while (b) b ^= a ^= b ^= a %= b; return b;}
ll big(ll b, ll p, ll m){ll h = big(b, p / 2, m); return h * h % m * ((p % 2) ? b : 1) % m;}
ll mod = 1000000007;
//look at constraints plz (brute force???)
/*
void solve(){

}
int main(){
	ll t;
	cin >> t;
	while (t--) solve();
}
*/
int main(){
	ll n;
	cin >> n;
	ll a[n];
	for (ll i = 0; i < n; i++) cin >> a[i];
	for (ll i = 0; i < n; i++){
		for (ll j = 0; j < n; j++){
			a[j] = a[j] + ((j % 2) ? -1 : 1) + n;
			a[j] %= n;
		}
		bool sad = false;
		for (ll j = 0; j < n; j++){
			if (a[j] != j) sad = true;
		}
		if (!sad){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
}


#include<bits/stdc++.h>
using namespace std;

/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

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

///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

///.............................................................TEMPLATE................................................./////

//long long  Prime[3000000],nPrime;
//long long  mark[10000002];
//
//void seive(long long int n)
//{
//	long long int i,j,limit=sqrt(n*1.0)+2;
//	mark[1]=1;
//	for(i=4; i<=n ;i+=2)
//	mark[i]=1;
//	Prime[nPrime++]=2;
//	for(i=3; i<=n; i+=2)
//	{
//		if(!mark[i])
//		{
//			Prime[nPrime++]=i;
//			if(i<=limit)
//			{
//				for(j=i*i; j<=n ;j+=i*2)
//				{
//					mark[j]=1;
//				}
//			}
//		}
//	}
//}

int b[20003];

int main()
{
    FASTIO;

    int n ;

    cin >> n;

    int a[n+1];

    bool f = 0;

    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }

    set<int>s;

    for(int i=0; i<n; i++)
    {
        if(a[i]==i)
            continue;
        if(i%2)
        {
            if(a[i]>i)
            {
                b[i] = (a[i]-i);
                //cout << a[i]-i << endl;

            }
            else
            {
                b[i] = (a[i]+n-i);
               // cout << a[i] + n - i << endl;

            }

        }
        else
        {
            if(a[i]>i)
            {
                b[i]=(n-a[i]+i);
            }
            else
            {
                b[i] = (i-a[i]);
            }
        }
    }

    for(int i=0; i<n; i++)
    {
        s.insert(b[i]);

    }

    if(s.size()==1)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define sc scanf
#define pb push_back

int n;
int a[1005];

bool ok() {

    for(int i=1; i<=n; ++i) {
        if(i - a[i] != 1) {
            return false;
        }
    }
    return true;
}

int main() {

    sc("%d", &n);

    for(int i=1; i<=n; ++i) {
        sc("%d", &a[i]);
    }

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

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

            if(j%2) {
                a[j]++;
                if(a[j] == n) {
                    a[j] = 0;
                }
            }
            else {
                a[j]--;
                if(a[j] == -1) {
                    a[j] = n-1;
                }
            }
        }

        if(ok()) {
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<set>
#include<cmath>
#define ll long long
using namespace std;
const int maxn=1005;
int a[maxn];
int n;
int cnt1,cnt2;
bool solve1(){
	int now=a[1];
	cnt1=0;
	int key;
	while(1){
		for(int i=1;i<=n;i+=2){
			a[i]=(a[i]+1)%n;
		}
		cnt1++;
		key=0;
		for(int i=1;i<=n;i+=2){
			if(a[i]==i-1)continue;
			else{
				key=1;break;
			}
		}
		if(key==0)return true;
		if(a[1]==now)break;
	}
//	cout<<"aa";
	return false;
}
bool solve2(){
	int now=a[2];
	cnt2=0;
	int key;
	while(1){
		for(int i=2;i<=n;i+=2){
			a[i]=(a[i]-1+n)%n;
		}
		cnt2++;
		key=0;
		for(int i=2;i<=n;i+=2){
			if(a[i]==i-1)continue;
			else{
				key=1;break;
			}
		}
		if(key==0)return true;
		if(a[2]==now)break;
	}
	//cout<<"bb";
	return false;
}
int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	if(n==1){
		cout<<"Yes\n";return 0;
	}
	if(solve1()&&solve2()){
		if(cnt1==cnt2)cout<<"Yes\n";
		else cout<<"No\n";
	}
	else cout<<"No\n";
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<set>
#include<cmath>
#define ll long long
using namespace std;
const int maxn=1005;
int a[maxn];
int n;
int cnt1,cnt2;
bool solve1(){
	int now=a[1];
	cnt1=0;
	int key;
	while(1){
		for(int i=1;i<=n;i+=2){
			a[i]=(a[i]+1)%n;
		}
		cnt1++;
		if(a[1]==now)break;
		key=0;
		for(int i=1;i<=n;i+=2){
			if(a[i]==i-1)continue;
			else{
				key=1;break;
			}
		}
		if(key==0)return true;
	}
//	cout<<"aa";
	return false;
}
bool solve2(){
	int now=a[2];
	cnt2=0;
	int key;
	while(1){
		for(int i=2;i<=n;i+=2){
			a[i]=(a[i]-1+n)%n;
		}
		cnt2++;
		if(a[2]==now)break;
		key=0;
		for(int i=2;i<=n;i+=2){
			if(a[i]==i-1)continue;
			else{
				key=1;break;
			}
		}
		if(key==0)return true;
	}
	//cout<<"bb";
	return false;
}
int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	if(n==1){
		cout<<"Yes\n";return 0;
	}
	if(solve1()&&solve2()){
		if(cnt1==cnt2)cout<<"Yes\n";
		else cout<<"No\n";
	}
	else cout<<"No\n";
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<set>
#include<cmath>
#define ll long long
using namespace std;
const int maxn=1005;
int a[maxn];
int n;
bool solve1(){
	int now=a[1];
	int key;
	while(1){
		for(int i=1;i<=n;i+=2){
			a[i]=(a[i]+1)%n;
		}
		if(a[1]==now)break;
		key=0;
		for(int i=1;i<=n;i+=2){
			if(a[i]==i-1)continue;
			else{
				key=1;break;
			}
		}
		if(key==0)return true;
	}
//	cout<<"aa";
	return false;
}
bool solve2(){
	int now=a[2];
	int key;
	while(1){
		for(int i=2;i<=n;i+=2){
			a[i]=(a[i]-1+n)%n;
		}
		if(a[2]==now)break;
		key=0;
		for(int i=2;i<=n;i+=2){
			if(a[i]==i-1)continue;
			else{
				key=1;break;
			}
		}
		if(key==0)return true;
	}
	//cout<<"bb";
	return false;
}
int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	if(solve1()&&solve2())cout<<"Yes\n";
	else cout<<"No\n";
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<set>
#include<cmath>
#define ll long long
using namespace std;
const int maxn=1005;
int a[maxn];
int n;
bool solve1(){
	int now=a[1];
	int key;
	while(1){
		for(int i=1;i<=n;i+=2){
			a[i]=(a[i]+1)%n;
		}
		if(a[1]==now)break;
		key=0;
		for(int i=1;i<=n;i+=2){
			if(a[i]==i-1)continue;
			else{
				key=1;break;
			}
		}
		if(key==0)return true;
	}
//	cout<<"aa";
	return false;
}
bool solve2(){
	int now=a[2];
	int key;
	while(1){
		for(int i=2;i<=n;i+=2){
			a[i]=(a[i]-1+n)%n;
		}
		if(a[2]==now)break;
		key=0;
		for(int i=2;i<=n;i+=2){
			if(a[i]==i-1)continue;
			else{
				key=1;break;
			}
		}
		if(key==0)return true;
	}
	//cout<<"bb";
	return false;
}
int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	if(n==1){
		cout<<"Yes\n";return 0;
	}
	if(solve1()&&solve2())cout<<"Yes\n";
	else cout<<"No\n";
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector <int> arr,ans;
    for(int i=0;i<n;i++)
    {   int a;
        cin>>a;
        arr.push_back(a);
        ans.push_back(i);
    }
    int flag=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j%2==0) arr[i]=(arr[i]+1)%n;
            else arr[i]=(arr[i]+n-1)%n;
        }
        if(arr==ans) {flag=1;break;}
    }
    if(flag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector <int> arr,ans;
    for(int i=0;i<n;i++)
    {   int a;
        cin>>a;
        arr.push_back(a);
        ans.push_back(i);
    }
    int flag=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j%2==0) arr[i]=(arr[i]+1)%n;
            else arr[i]=(arr[i]+n-1)%n;
        }
        sort(arr.begin(),arr.end());
        if(arr==ans) {flag=1;break;}
    }
    if(flag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector <int> arr,ans;
    for(int i=0;i<n;i++)
    {   int a;
        cin>>a;
        arr.push_back(a);
        ans.push_back(i);
    }
    int flag=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j%2==0) arr[j]=(arr[j]+1)%n;
            else arr[j]=(arr[j]+n-1)%n;
        }
        if(arr==ans) {flag=1;break;}
    }
    if(flag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#pragma GCC optimize ("O3")
using namespace std;
int main () {
    ios::sync_with_stdio(false);
    cin.tie (0);
    int n; cin>>n;
    set <int> diff;
    for (int i=0;i<n;++i) {
        int a; cin>>a;
        if (i%2==0) diff.insert((i-a+(i-a<0? n : 0))%n);
        else diff.insert((a-i+(a-i<0? n : 0))%n);
    }
    if (diff.size()==1) cout<<"Yes";
    else cout<<"No";
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#pragma GCC optimize ("O3")
using namespace std;
int main () {
    ios::sync_with_stdio(false);
    cin.tie (0);
    int n; cin>>n;
    set <int> diff;
    for (int i=0;i<n;++i) {
        int a; cin>>a;
        if (i%2==0) diff.insert((i-a+(i-a<0? n : 0))%n);
        else diff.insert((a-i+(a-i<0? n : 0))%n);
        if (diff.size()>1) {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


//
//  main.cpp
//  556B
//
//  Created by Parsa Alimohammadi on 6/15/1399 AP.
//  Copyright © 1399 Parsa Alimohammadi. All rights reserved.
//

#include <iostream>

using namespace std;

int n,a[1002];

int main() {

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

    bool ans = false;
    for (int i=0; i<n; i++)
    {
        bool check = true;

        for (int j=0; j<n; j++)
        {
            a[j] += j%2==0? 1 : -1;

            a[j] = a[j]==-1? n-1 : a[j]==n? 0 : a[j];

            if (j != a[j])
                check = false;

        }

        check == false? check = false : ans = true;
    }

    ans == false? cout << "No" : cout << "Yes";
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c)              c.begin(), c.end()
#define CC(x) cout << (x) << endl
#define rep(i,n) for(int i=0;i<n;i++)
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define EPS 1e-9
#define sz(v) int((v).size())
const unsigned long long inf=1e15;
const int range=1e6;
const long long inff=1e-12;
const int dx[] = { 0, 1, -1, 0 };
const int dy[] = { -1, 0, 0, 1 };
typedef unsigned long long ull;
int gcd(ull a, ull b) {if (b == 0)return a;return gcd(b, a % b);}
using namespace std;
bool cmp(const pair<ll,ll>&a, const pair<ll,ll>&b){return (a.se>b.se);}
int main()
{
    FastRead
    ull x,y,z,t,cas=1,a=0,b=0,d,c,k;
    cin >> x;
    vector<int>v(x);
    for(int i=0;i<x;i++){
        cin >>v[i];
    }
    if(v[0]==0){
        int f=0;
        for(int i=0;i<x;i++){
            if(v[i]!=i){
                f=1;
                break;
            }
        }
        if(f==1){
           cout <<"NO"<<endl;
        }
        else
            cout <<"YES"<<endl;
    }
    else
    {
        while(1){
            if(v[0]==0)
                break;
            v[0]=v[0]+1;
            //cout<< v[0]<<endl;
            if(v[0]==(x)){
               v[0]=0;
            }
            a++;
        }
        for(int i=1;i<x;i++){
            b=a;
            if(i&1){
                while(b--){
                    v[i]=v[i]-1;
                    if(v[i]==-1){
                        v[i]=(x-1);
                    }
                }
            }
            else
            {
                while(b--){
                    v[i]=v[i]+1;
                    if(v[i]==x){
                        v[i]=0;
                    }
                }
            }
        }
        int f=0;
        for(int i=0;i<x;i++){
            if(v[i]!=i){
                f=1;
                break;
            }
        }
        if(f==1){
            cout << "NO"<<endl;
        }
        else
            cout <<"YES"<<endl;
    }
    main();
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c)              c.begin(), c.end()
#define CC(x) cout << (x) << endl
#define rep(i,n) for(int i=0;i<n;i++)
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define EPS 1e-9
#define sz(v) int((v).size())
const unsigned long long inf=1e15;
const int range=1e6;
const long long inff=1e-12;
const int dx[] = { 0, 1, -1, 0 };
const int dy[] = { -1, 0, 0, 1 };
typedef unsigned long long ull;
int gcd(ull a, ull b) {if (b == 0)return a;return gcd(b, a % b);}
using namespace std;
bool cmp(const pair<ll,ll>&a, const pair<ll,ll>&b){return (a.se>b.se);}
int main()
{
    FastRead
    ull x,y,z,t,cas=1,a=0,b=0,d,c,k;
    cin >> x;
    vector<int>v(x);
    for(int i=0;i<x;i++){
        cin >>v[i];
    }
    if(v[0]==0){
        int f=0;
        for(int i=0;i<x;i++){
            if(v[i]!=i){
                f=1;
                break;
            }
        }
        if(f==1){
           cout <<"NO"<<endl;
        }
        else
            cout <<"YES"<<endl;
    }
    else
    {
        while(1){
            if(v[0]==0)
                break;
            v[0]=v[0]+1;
            //cout<< v[0]<<endl;
            if(v[0]==(x)){
               v[0]=0;
            }
            a++;
        }
        for(int i=1;i<x;i++){
            b=a;
            if(i&1){
                while(b--){
                    v[i]=v[i]-1;
                    if(v[i]==-1){
                        v[i]=(x-1);
                    }
                }
            }
            else
            {
                while(b--){
                    v[i]=v[i]+1;
                    if(v[i]==x){
                        v[i]=0;
                    }
                }
            }
        }
        int f=0;
        for(int i=0;i<x;i++){
            if(v[i]!=i){
                f=1;
                break;
            }
        }
        if(f==1){
            cout << "NO"<<endl;
        }
        else
            cout <<"YES"<<endl;
    }
    //main();
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
#define vi vector<long long int>
#define pb push_back
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b, long long m)
{
   long long res = 1;
   while (b > 0)
   {
      if (b & 1)
         res = res * a % m;
      a = a * a % m;
      b >>= 1;
   }
   return res;
}

signed main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(0);

#ifndef ONLINE_JUDGE
   if (fopen("INPUT.txt", "r"))
   {
      freopen("INPUT.txt", "r", stdin);
      freopen("OUTPUT.txt", "w", stdout);
   }
#endif
    //9:22
    int n;
    cin>>n;
    vector<int> vec(n);
   for(int i=0;i<n;i++)
      cin>>vec[i];
      // cout<<"gweyh"<<endl;
   bool ok=true;
   int z=n-vec[0];
   for(int i=1;i<n;i++){
      // cout<<i<<endl;
      if(i%2==1){
         // cout<<"rgsdf"<<endl;
         if((n+vec[i]-z)%n!=i)
            ok=false;
      }else {
         // cout<<"svas"<<endl;
         if((vec[i]+z)%n!=i)
            ok=false;
      }
   }
   if(ok)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define pb push_back
#define tp make_tuple
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
#define r0 return 0
using namespace std;

int main()
{
    ll n,m,i,j,k,l,t,x,y;

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    cin>>n;

    ll a[n+5];

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

        cin>>a[i];
    }

    ll b[n+5];

    memset(b,0,sizeof(b));

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

        if(i%2)
        {

            if(a[i]>i)
            {

                b[i]=a[i]-i;
            }
            else
            {

                b[i]=a[i]+n-i;
            }
        }

            else
            {

                if(a[i]>i)
                {

                    b[i]=n-a[i]+i;
                }
                else
                {

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

       /* for(i=0;i<n;i++){

            cout<<b[i]<<" ";
        }*/

    set<ll>s;

    for(i=0;i<n;i++)s.insert(b[i]);

    if(s.size()==1)puts("Yes");
    else puts("No");

}


import java.util.*;

import sun.tools.tree.ThisExpression;

import java.io.*;

public class cf {

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while (t-- > 0) {
			int n = sc.nextInt(), k = sc.nextInt();
			arr = new int[n];
			int[] y = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				y[i] = sc.nextInt();
			}
			Arrays.sort(arr);
			p2[] ans = new p2[n];
			for (int i = 0; i < y.length; i++) {
				ans[i] = new p2(new pair(i - upper(i, arr[i] - k) + 1, i), new pair(lower(i, arr[i] + k) - i + 1, i));
			}
			int max = 0;
			for (int i = 1; i < ans.length; i++) {
				if (ans[i - 1].x.x > ans[i].x.x) {
					ans[i].x = ans[i - 1].x;
				}
			}
			for (int i = ans.length - 2; i >= 0; i--) {
				if (ans[i + 1].y.x > ans[i].y.x) {
					ans[i].y = ans[i + 1].y;
				}
			}
			for (int i = 0; i < ans.length; i++) {
				max = Math.max(max, ans[i].x.x + ans[i].y.x + (ans[i].x.y == ans[i].y.y ? -1 : 0));
			}
			pw.println(max);
//			pw.println(Arrays.toString(ans));
		}
		pw.close();
	}

	public static class p2 {
		pair x, y;

		public String toString() {
			return x + " " + y;
		}

		public p2(pair x, pair y) {
			this.x = x;
			this.y = y;
		}
	}

	static int[] arr;

	static int lower(int s, int x) {
		int start = s, end = arr.length - 1, ans = -1;
		while (start <= end) {
			int mid = (start + end) / 2;
			if (arr[mid] > x) {
				end = mid - 1;
			} else {
				ans = mid;
				start = mid + 1;
			}
		}
		return ans;
	}

	static int upper(int e, int x) {
		int start = 0, end = e, ans = -1;
		while (start <= end) {
			int mid = (start + end) / 2;
			if (arr[mid] < x) {
				start = mid + 1;
			} else {
				ans = mid;
				end = mid - 1;
			}
		}
		return ans;
	}

	static long pow(long a, long e) {
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res *= a;
			a *= a;
			e >>= 1;
		}
		return res;
	}

	static int sod(long n) {
		int a = 0;
		while (n > 0) {
			a += n % 10;
			n /= 10;
		}
		return a;
	}

	static PrintWriter pw = new PrintWriter(System.out);

	public static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x == x && p.y == y;
			}
			return false;
		}

		public int hashCode() {
			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return Long.compare(this.y, other.y);
			}
			return Long.compare(this.x, other.x);
		}
	}

	public static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				if (this.y == other.y)
					return this.z - other.z;
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class SegmentTree {
		int size;
		int[] st;

		public String toString() {
			return Arrays.toString(st);
		}

		void init(int n) {
			size = 1;
			while (size < n)
				size *= 2;
			st = new int[2 * size];
		}

		void build(int[] arr) {
			build(arr, 0, 0, size);
		}

		void build(int[] arr, int x, int lx, int rx) {
			if (rx - lx == 1) {
				if (lx < arr.length) {
					st[x] = arr[lx];
				}
				return;
			}
			int m = (lx + rx) >> 1;
			build(arr, 2 * x + 1, lx, m);
			build(arr, 2 * x + 2, m, rx);
			st[x] = st[2 * x + 1] + st[2 * x + 2];
		}

		void set(int i, int v) {
			set(i, v, 0, 0, size);
		}

		void set(int i, int v, int x, int l, int r) {
			if (r - l == 1) {
				st[x] = v;
				return;
			}
			int m = (l + r) >> 1;
			if (i < m) {
				set(i, v, 2 * x + 1, l, m);
			} else {
				set(i, v, 2 * x + 2, m, r);
			}
			st[x] = st[2 * x + 1] + st[2 * x + 2];
		}

		long get(int l, int r) {
			return get(l, r + 1, 0, 0, size);
		}

		long get(int l, int r, int x, int lx, int rx) {
			if (lx >= r || rx <= l) {
				return 0;
			} else if (lx >= l && rx <= r) {
				return st[x];
			}
			int m = (lx + rx) >> 1;
			return get(l, r, 2 * x + 1, lx, m) + get(l, r, 2 * x + 2, m, rx);
		}

		int find(int idx) {
			return find(idx, 0);
		}

		int find(int idx, int node) {
			if (node >= size - 1) {
				return node - size + 1;
			}
//			pw.print(node + " ");
			if (st[node * 2 + 1] > idx) {
				return find(idx, node * 2 + 1);
			} else {
				return find(idx - st[node * 2 + 1], node * 2 + 2);
			}
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


import java.util.*;
import java.io.*;

public class cf {

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while (t-- > 0) {
			int n = sc.nextInt(), k = sc.nextInt();
			arr = new int[n];
			int[] y = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				y[i] = sc.nextInt();
			}
			Arrays.sort(arr);
			if (n == 1) {
				pw.println(1);
			} else if (2 * k >= arr[n - 1] - arr[0]) {
				pw.println(n);
			} else {
				p2[] ans = new p2[n];
				for (int i = 0; i < y.length; i++) {
					ans[i] = new p2(new pair(i - upper(i, arr[i] - k) + 1, i),
							new pair(lower(i, arr[i] + k) - i + 1, i));
				}
				int max = 0;
				for (int i = 1; i < ans.length; i++) {
					if (ans[i - 1].x.x > ans[i].x.x) {
						ans[i].x = ans[i - 1].x;
					}
				}
				for (int i = ans.length - 2; i >= 0; i--) {
					if (ans[i + 1].y.x > ans[i].y.x) {
						ans[i].y = ans[i + 1].y;
					}
				}
				for (int i = 0; i < ans.length; i++) {
					max = Math.max(max, ans[i].x.x + ans[i].y.x + (ans[i].x.y == ans[i].y.y ? -1 : 0));
				}
				pw.println(max);
//				pw.println(Arrays.toString(ans));
			}
		}
		pw.close();
	}

	public static class p2 {
		pair x, y;

		public String toString() {
			return x + " " + y;
		}

		public p2(pair x, pair y) {
			this.x = x;
			this.y = y;
		}
	}

	static int[] arr;

	static int lower(int s, int x) {
		int start = s, end = arr.length - 1, ans = -1;
		while (start <= end) {
			int mid = (start + end) / 2;
			if (arr[mid] > x) {
				end = mid - 1;
			} else {
				ans = mid;
				start = mid + 1;
			}
		}
		return ans;
	}

	static int upper(int e, int x) {
		int start = 0, end = e, ans = -1;
		while (start <= end) {
			int mid = (start + end) / 2;
			if (arr[mid] < x) {
				start = mid + 1;
			} else {
				ans = mid;
				end = mid - 1;
			}
		}
		return ans;
	}

	static long pow(long a, long e) {
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res *= a;
			a *= a;
			e >>= 1;
		}
		return res;
	}

	static int sod(long n) {
		int a = 0;
		while (n > 0) {
			a += n % 10;
			n /= 10;
		}
		return a;
	}

	static PrintWriter pw = new PrintWriter(System.out);

	public static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x == x && p.y == y;
			}
			return false;
		}

		public int hashCode() {
			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return Long.compare(this.y, other.y);
			}
			return Long.compare(this.x, other.x);
		}
	}

	public static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				if (this.y == other.y)
					return this.z - other.z;
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class SegmentTree {
		int size;
		int[] st;

		public String toString() {
			return Arrays.toString(st);
		}

		void init(int n) {
			size = 1;
			while (size < n)
				size *= 2;
			st = new int[2 * size];
		}

		void build(int[] arr) {
			build(arr, 0, 0, size);
		}

		void build(int[] arr, int x, int lx, int rx) {
			if (rx - lx == 1) {
				if (lx < arr.length) {
					st[x] = arr[lx];
				}
				return;
			}
			int m = (lx + rx) >> 1;
			build(arr, 2 * x + 1, lx, m);
			build(arr, 2 * x + 2, m, rx);
			st[x] = st[2 * x + 1] + st[2 * x + 2];
		}

		void set(int i, int v) {
			set(i, v, 0, 0, size);
		}

		void set(int i, int v, int x, int l, int r) {
			if (r - l == 1) {
				st[x] = v;
				return;
			}
			int m = (l + r) >> 1;
			if (i < m) {
				set(i, v, 2 * x + 1, l, m);
			} else {
				set(i, v, 2 * x + 2, m, r);
			}
			st[x] = st[2 * x + 1] + st[2 * x + 2];
		}

		long get(int l, int r) {
			return get(l, r + 1, 0, 0, size);
		}

		long get(int l, int r, int x, int lx, int rx) {
			if (lx >= r || rx <= l) {
				return 0;
			} else if (lx >= l && rx <= r) {
				return st[x];
			}
			int m = (lx + rx) >> 1;
			return get(l, r, 2 * x + 1, lx, m) + get(l, r, 2 * x + 2, m, rx);
		}

		int find(int idx) {
			return find(idx, 0);
		}

		int find(int idx, int node) {
			if (node >= size - 1) {
				return node - size + 1;
			}
//			pw.print(node + " ");
			if (st[node * 2 + 1] > idx) {
				return find(idx, node * 2 + 1);
			} else {
				return find(idx - st[node * 2 + 1], node * 2 + 2);
			}
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}