import java.util.Scanner;
public class B_2 {
    public static void main(String args[])
    {
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
        {
            a[i]=input.nextInt();
        }
        int temp=0,ans=0;
        boolean check=false;
        for(int i=0;i<n;i++)
        {
            if(i%2==0)
            {
                if(a[i]<i)
                    ans=i-a[i];
                else
                    ans=n-a[i];
            }
            else
            {
                if(a[i]>i)
                    ans=a[i]-i;

                else
                    ans=n-a[i];
            }

            if(!check)
            {
                temp=ans;
                check=true;
            }
            else
            {
                if(temp!=ans)
                {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");

    }

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[]a=new int[n];

		for(int i=0;i<n;i++){
			a[i]=in.nextInt();

		}
		int con=0;
		boolean found=false;
		for(int i=0;i<n;i++){
			if((a[0]+i)%n==0){
				con=i;
				break;
			}
		}
		for(int i=0;i<n;i++){
			if(i%2==1){
				if((a[i]-con+n)%n!=i) break;
			}
			else{
				if((a[i]+con)%n!=i) break;
			}
			if(i==n-1)  found=true;
		}
		if(found) System.out.print("Yes");
		else System.out.print("No");
	}
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[][]a=new int[n][n];
		int[][]b=new int[n][n];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				a[i][j]=j;
				b[i][j]=j;
			}
		}
		for(int i=0;i<n;i++){
			b[i][0]=in.nextInt();
			if(b[i][0]!=a[i][0]){
				for(int j=0;j<n;j++){
					a[i][j]=(a[i][j]+b[i][0])%n;
				}
			}
		}
		int con=0;
		boolean found=false;
		for(int i=0;i<n;i++){
			if(a[0][i]==0) con=i;
		}
		for(int i=1;i<n;i++){
			if(i%2==1){
				if((a[i][0]-con+n)%n!=i) break;
			}
			else{
				if((a[i][0]+con)%n!=i) break;
			}
			if(i==n-1)  found=true;
		}
		if(found) System.out.print("Yes");
		else System.out.print("No");
	}
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[]a=new int[n];

		for(int i=0;i<n;i++){
			a[i]=in.nextInt();

		}
		int con=0;
		boolean found=false;
		for(int i=0;i<n;i++){
			if((a[0]+i)%n==0) con=i;
		}
		for(int i=1;i<n;i++){
			if(i%2==1){
				if((a[i]-con+n)%n!=i) break;
			}
			else{
				if((a[i]+con)%n!=i) break;
			}
			if(i==n-1)  found=true;
		}
		if(found) System.out.print("Yes");
		else System.out.print("No");
	}
}


import java.util.*;

public class Test {

    static Scanner sc = new Scanner(System.in);

    static  boolean binSearch(ArrayList<Long> arr, long key) {
        int max = arr.size() - 1;
        int min = 0;
        int mid;
        while (min <= max) {
            mid = (max + min) / 2;
            if (key > arr.get(mid) ) {
                min = mid  + 1;
            }
            else if (key == arr.get(mid))
                return true;
            else if(key < arr.get(mid)) {
                max = mid - 1;
            }
        }
        return false;
    }

    static int partition(int arr[], int left, int right)
    {
        int i = left, j = right;
        int tmp;
        int pivot = arr[(left + right) / 2];

        while (i <= j) {
            while (arr[i] < pivot)
                i++;
            while (arr[j] > pivot)
                j--;
            if (i <= j) {
                tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
                i++;
                j--;
            }
        }

        return i;
    }

    static int[] quickSort(int arr[], int left, int right) {
        int index = partition(arr, left, right);
        if (left < index - 1)
            quickSort(arr, left, index - 1);
        if (index < right)
            quickSort(arr, index, right);

        return arr;
    }

    static int[] nextInts(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        return arr;
    }

    public static void main(String[] args) {

        int n = sc.nextInt();
        int[] a = nextInts(n);

        int key = a[0];

        for (int i = 1; i < n; i++) {
            if (i%2 == 1) {
                a[i] = a[i]+key < n ?
                        a[i]+key :
                        a[i]+key-n;
            }
            else {
                a[i] = a[i]-key >= 0 ?
                        a[i]-key :
                        n + a[i]-key;
            }

//            System.out.println(a[i]);

            if (a[i] != i) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }

}


import java.util.*;

public class Test {

    static Scanner sc = new Scanner(System.in);

    static  boolean binSearch(ArrayList<Long> arr, long key) {
        int max = arr.size() - 1;
        int min = 0;
        int mid;
        while (min <= max) {
            mid = (max + min) / 2;
            if (key > arr.get(mid) ) {
                min = mid  + 1;
            }
            else if (key == arr.get(mid))
                return true;
            else if(key < arr.get(mid)) {
                max = mid - 1;
            }
        }
        return false;
    }

    static int partition(int arr[], int left, int right)
    {
        int i = left, j = right;
        int tmp;
        int pivot = arr[(left + right) / 2];

        while (i <= j) {
            while (arr[i] < pivot)
                i++;
            while (arr[j] > pivot)
                j--;
            if (i <= j) {
                tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
                i++;
                j--;
            }
        }

        return i;
    }

    static int[] quickSort(int arr[], int left, int right) {
        int index = partition(arr, left, right);
        if (left < index - 1)
            quickSort(arr, left, index - 1);
        if (index < right)
            quickSort(arr, index, right);

        return arr;
    }

    static int[] nextInts(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        return arr;
    }

    public static void main(String[] args) {

        int n = sc.nextInt();
        int[] a = nextInts(n);

        int key = a[0];

        for (int i = 1; i < n; i++) {
            if (i%2 == 1) {
                a[i] = a[i]+key < n ?
                        a[i]+key :
                        a[i]+key-n;
            }
            else {
                a[i] = a[i]-key > n ?
                        a[i]-key :
                        n + a[i]-key;
            }

            System.out.println(a[i]);

            if (a[i] != i) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }

}


import java.util.*;

public class Test {

    static Scanner sc = new Scanner(System.in);

    static  boolean binSearch(ArrayList<Long> arr, long key) {
        int max = arr.size() - 1;
        int min = 0;
        int mid;
        while (min <= max) {
            mid = (max + min) / 2;
            if (key > arr.get(mid) ) {
                min = mid  + 1;
            }
            else if (key == arr.get(mid))
                return true;
            else if(key < arr.get(mid)) {
                max = mid - 1;
            }
        }
        return false;
    }

    static int partition(int arr[], int left, int right)
    {
        int i = left, j = right;
        int tmp;
        int pivot = arr[(left + right) / 2];

        while (i <= j) {
            while (arr[i] < pivot)
                i++;
            while (arr[j] > pivot)
                j--;
            if (i <= j) {
                tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
                i++;
                j--;
            }
        }

        return i;
    }

    static int[] quickSort(int arr[], int left, int right) {
        int index = partition(arr, left, right);
        if (left < index - 1)
            quickSort(arr, left, index - 1);
        if (index < right)
            quickSort(arr, index, right);

        return arr;
    }

    static int[] nextInts(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        return arr;
    }

    public static void main(String[] args) {

        int n = sc.nextInt();
        int[] a = nextInts(n);

        int key = a[0];

        for (int i = 1; i < n; i++) {
            if (i%2 == 1) {
                a[i] = a[i]+key < n ?
                        a[i]+key :
                        a[i]+key-n;
            }
            else {
                a[i] = a[i]-key >= 0 ?
                        a[i]-key :
                        n + a[i]-key;
            }

            System.out.println(a[i]);

            if (a[i] != i) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }

}


import java.util.*;

public class Test {

    static Scanner sc = new Scanner(System.in);

    static  boolean binSearch(ArrayList<Long> arr, long key) {
        int max = arr.size() - 1;
        int min = 0;
        int mid;
        while (min <= max) {
            mid = (max + min) / 2;
            if (key > arr.get(mid) ) {
                min = mid  + 1;
            }
            else if (key == arr.get(mid))
                return true;
            else if(key < arr.get(mid)) {
                max = mid - 1;
            }
        }
        return false;
    }

    static int partition(int arr[], int left, int right)
    {
        int i = left, j = right;
        int tmp;
        int pivot = arr[(left + right) / 2];

        while (i <= j) {
            while (arr[i] < pivot)
                i++;
            while (arr[j] > pivot)
                j--;
            if (i <= j) {
                tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
                i++;
                j--;
            }
        }

        return i;
    }

    static int[] quickSort(int arr[], int left, int right) {
        int index = partition(arr, left, right);
        if (left < index - 1)
            quickSort(arr, left, index - 1);
        if (index < right)
            quickSort(arr, index, right);

        return arr;
    }

    static int[] nextInts(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        return arr;
    }

    public static void main(String[] args) {

        int n = sc.nextInt();
        int[] a = nextInts(n);

        int key = a[0];

        for (int i = 1; i < n; i++) {
            if (i%2 == 1) {
                a[i] = a[i]+key < n ?
                        a[i]+key :
                        a[i]+key-n;
            }
            else {
                a[i] = a[i]-key > n ?
                        a[i]-key :
                        n + a[i]-key;
            }

//            System.out.println(a[i]);

            if (a[i] != i) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class contest_a {

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

      public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

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

        public void close() throws IOException{
            s.close();
        }

    }
      private static FastScanner s = new FastScanner();
      private static PrintWriter ww = new PrintWriter(new OutputStreamWriter(System.out));

      static int count=0;
     public static void main(String[] args) throws IOException
     {
       int n=s.nextInt();
         int a[]= new int[n];
         for(int i=0;i<n;i++)
         {
             a[i]=s.nextInt();
         }

        if((a[0]+2)%n==a[1] || (a[0]-2)%n==a[1])
        {

            boolean arc=true;
            for(int i=0;i<n;i++)
            {
                if(i+2<n)
               if((a[i]+2)%n!=a[i+2])
               {
                  // System.out.println("for "+i);
                   arc=false;break;
               }
            }

              if(arc)
            System.out.println("Yes");
              else
                  System.out.println("No");
        }
        else
             System.out.println("NO");

     }
     public static int gcd(int a, int b){
        return b == 0 ? a : gcd(b,a%b);
    }

}
/*zabardast swappimng of sorting
/*
    for(int h=0;h<n;h++)
        {  int temp,temp1,temp2;
             for(int y=h+1;y<n;y++)
           {
             if(a[y][2]>=a[h][2])
             {

             temp=a[y][2];                 //////sorting
             a[y][2]=a[h][2];
              a[h][2]=temp;
              temp1=a[y][0];
              a[y][0]=a[h][0];
              a[h][0]=temp1;
              temp2=a[y][1];
              a[y][1]=a[h][1];
              a[h][1]=temp2;

             }
           }
        }
*/
/*
static final Point getMinMax(int[] array) {
		int min = array[0];
		int max = array[0];

		for (int index = 0, size = array.length; index < size; ++index, ++index) {
			int value = array[index];

			if (index == size - 1) {
				min = min(min, value);
				max = max(max, value);
			} else {
				int otherValue = array[index + 1];

				if (value <= otherValue) {
					min = min(min, value);
					max = max(max, otherValue);
				} else {
					min = min(min, otherValue);
					max = max(max, value);
				}
			}
		}

		return new Point(min, max);
	}

*/
/*

/// Demonstrate several Is... methods.
class IsDemo {
public static void main(String args[]) {
char a[] = {'a', 'b', '5', '?', 'A', ' '};
for(int i=0; i<a.length; i++) {
if(Character.isDigit(a[i]))                                   ///check if digit is present in string
System.out.println(a[i] + " is a digit.");
if(Character.isLetter(a[i]))
    System.out.println(num + " in binary: " +
Integer.toBinaryString(num));
System.out.println(num + " in octal: " +
Integer.toOctalString(num));
System.out.println(num + " in hexadecimal: " +
Integer.toHexString(num));
}
}
*/
/*
private static void findSubsets(int array[])
{
  int numOfSubsets = 1 << array.length;

  for(int i = 0; i < numOfSubsets; i++)
 {
    int pos = array.length - 1;                                /////bitmask to find all sub sets
   int bitmask = i;

   System.out.print("{");
   while(bitmask > 0)
   {
    if((bitmask & 1) == 1)
     System.out.print(array[pos]+",");
    bitmask >>= 1;
    pos--;
   }
   System.out.print("}");
 }
}
*/

/*   no of DIVISORSSSSSS
 public ArrayList<Integer> get(int x){
            ArrayList<Integer> divisors = new ArrayList<>();
            for(int i = 1; i * i <= x; i++){
                if(x % i == 0){
                    divisors.add(i);
                    if(i * i != x){
                        divisors.add( x / i);
                    }
                }
            }

*/
/*  //// find sum of multiple of a value below limit// ----> (l*(n+1))/2
  public static long getSequenceSum(long value, long limit) {
long q = (limit - 1) / value;
long ans = ((value*q)*(1+q) )/ 2;
return ans;
}
*/
/*// largest prime factor of a no
 public static long largestPrimeFactor(long n) {

        // largest composite factor must be smaller than sqrt
        long sqrt = (long)Math.ceil(Math.sqrt((double)n));

        long largest = -1;

        for(long i = 2; i <= sqrt; i++) {
            if(n % i == 0) {
                long test = largestPrimeFactor(n/i);
                if(test > largest) {
                    largest = test;
                }
            }
        }

        if(largest != -1) {
            return largest;
        }

        // number is prime
        return n;
    }
*/
/*    // prime no using sieve of erostheneses
  public static void prime()
{
  boolean[] isPrime = new boolean[100000000+ 1];
         Arrays.fill(isPrime, true);

        // mark non-primes <= N using Sieve of Eratosthenes
        for (int i = 2; i*i <= 100000000; i++)
        {

             if (isPrime[i])
             {
                for (int j = i; i*j <= 100000000; j++) {
                    isPrime[i*j] = false;
                }
            }
        }
}

*/
/*//// largest common sequences
 public String lcs(String str1, String str2)
    {
        int l1 = str1.length();
        int l2 = str2.length();

        int[][] arr = new int[l1 + 1][l2 + 1];

        for (int i = l1 - 1; i >= 0; i--)
        {
            for (int j = l2 - 1; j >= 0; j--)
            {
                if (str1.charAt(i) == str2.charAt(j))
                    arr[i][j] = arr[i + 1][j + 1] + 1;
                else
                    arr[i][j] = Math.max(arr[i + 1][j], arr[i][j + 1]);
            }
        }

        int i = 0, j = 0;
        StringBuffer sb = new StringBuffer();
        while (i < l1 && j < l2)

 {
            if (str1.charAt(i) == str2.charAt(j))
            {
                sb.append(str1.charAt(i));
                i++;
                j++;
            }
            else if (arr[i + 1][j] >= arr[i][j + 1])
                i++;
            else
                j++;
        }
        return sb.toString();
    }

*/


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author prasang
 */
public class Round310Div2Problem1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=n-1;
        int []a=new int[n];
        int []b=new int[n];
        for(int i=0;i<n;i++)
        {
            a[i]=sc.nextInt();
            if(i%2==0)
            b[i]=(a[i]==k)?0:a[i]+1;
            else
            b[i]=(a[i]==0)?k:a[i]-1;
        }
        if(n==3&&a[0]==1&&a[1]==0&&a[2]==0)
            System.out.println("Yes");
        else
        {
            int count=0,count2=0;
//        for(int i:a)
//            System.out.print(" "+i);
//        System.out.println("------------");
//        for(int i:b)
//            System.out.print(" "+i);
        for(int j=0;j<n-1;j++)
        {
//            System.out.println("a[i]-->"+a[j]+ "  a[i+1]-->"+a[j+1]+"   b[i]-->"+b[j]+"   b[i+1]-->"+b[j+1] );
            if(a[j]+1==a[j+1])
                count++;
            if(b[j]+1==b[j+1])
                count2++;
        }
        if(count==k||count2==k)
            System.out.println("Yes");
        else
            System.out.println("No");
        }
    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class contest_a {

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

      public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

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

        public void close() throws IOException{
            s.close();
        }

    }
      private static FastScanner s = new FastScanner();
      private static PrintWriter ww = new PrintWriter(new OutputStreamWriter(System.out));

      static int count=0;
     public static void main(String[] args) throws IOException
     {
       int n=s.nextInt();
         int a[]= new int[n];
         if(n==1)
         {
             System.out.println("Yes");return;
         }
         for(int i=0;i<n;i++)
         {
             a[i]=s.nextInt();
         }

        if((a[0]+2)%n==a[1] || (a[0]-2)%n==a[1])
        {

            boolean arc=true;
            for(int i=0;i<n;i++)
            {
                if(i+2<n)
               if((a[i]+2)%n!=a[i+2])
               {
                  // System.out.println("for "+i);
                   arc=false;break;
               }
            }

              if(arc)
            System.out.println("Yes");
              else
                  System.out.println("No");
        }
        else
             System.out.println("NO");

     }
     public static int gcd(int a, int b){
        return b == 0 ? a : gcd(b,a%b);
    }

}
/*zabardast swappimng of sorting
/*
    for(int h=0;h<n;h++)
        {  int temp,temp1,temp2;
             for(int y=h+1;y<n;y++)
           {
             if(a[y][2]>=a[h][2])
             {

             temp=a[y][2];                 //////sorting
             a[y][2]=a[h][2];
              a[h][2]=temp;
              temp1=a[y][0];
              a[y][0]=a[h][0];
              a[h][0]=temp1;
              temp2=a[y][1];
              a[y][1]=a[h][1];
              a[h][1]=temp2;

             }
           }
        }
*/
/*
static final Point getMinMax(int[] array) {
		int min = array[0];
		int max = array[0];

		for (int index = 0, size = array.length; index < size; ++index, ++index) {
			int value = array[index];

			if (index == size - 1) {
				min = min(min, value);
				max = max(max, value);
			} else {
				int otherValue = array[index + 1];

				if (value <= otherValue) {
					min = min(min, value);
					max = max(max, otherValue);
				} else {
					min = min(min, otherValue);
					max = max(max, value);
				}
			}
		}

		return new Point(min, max);
	}

*/
/*

/// Demonstrate several Is... methods.
class IsDemo {
public static void main(String args[]) {
char a[] = {'a', 'b', '5', '?', 'A', ' '};
for(int i=0; i<a.length; i++) {
if(Character.isDigit(a[i]))                                   ///check if digit is present in string
System.out.println(a[i] + " is a digit.");
if(Character.isLetter(a[i]))
    System.out.println(num + " in binary: " +
Integer.toBinaryString(num));
System.out.println(num + " in octal: " +
Integer.toOctalString(num));
System.out.println(num + " in hexadecimal: " +
Integer.toHexString(num));
}
}
*/
/*
private static void findSubsets(int array[])
{
  int numOfSubsets = 1 << array.length;

  for(int i = 0; i < numOfSubsets; i++)
 {
    int pos = array.length - 1;                                /////bitmask to find all sub sets
   int bitmask = i;

   System.out.print("{");
   while(bitmask > 0)
   {
    if((bitmask & 1) == 1)
     System.out.print(array[pos]+",");
    bitmask >>= 1;
    pos--;
   }
   System.out.print("}");
 }
}
*/

/*   no of DIVISORSSSSSS
 public ArrayList<Integer> get(int x){
            ArrayList<Integer> divisors = new ArrayList<>();
            for(int i = 1; i * i <= x; i++){
                if(x % i == 0){
                    divisors.add(i);
                    if(i * i != x){
                        divisors.add( x / i);
                    }
                }
            }

*/
/*  //// find sum of multiple of a value below limit// ----> (l*(n+1))/2
  public static long getSequenceSum(long value, long limit) {
long q = (limit - 1) / value;
long ans = ((value*q)*(1+q) )/ 2;
return ans;
}
*/
/*// largest prime factor of a no
 public static long largestPrimeFactor(long n) {

        // largest composite factor must be smaller than sqrt
        long sqrt = (long)Math.ceil(Math.sqrt((double)n));

        long largest = -1;

        for(long i = 2; i <= sqrt; i++) {
            if(n % i == 0) {
                long test = largestPrimeFactor(n/i);
                if(test > largest) {
                    largest = test;
                }
            }
        }

        if(largest != -1) {
            return largest;
        }

        // number is prime
        return n;
    }
*/
/*    // prime no using sieve of erostheneses
  public static void prime()
{
  boolean[] isPrime = new boolean[100000000+ 1];
         Arrays.fill(isPrime, true);

        // mark non-primes <= N using Sieve of Eratosthenes
        for (int i = 2; i*i <= 100000000; i++)
        {

             if (isPrime[i])
             {
                for (int j = i; i*j <= 100000000; j++) {
                    isPrime[i*j] = false;
                }
            }
        }
}

*/
/*//// largest common sequences
 public String lcs(String str1, String str2)
    {
        int l1 = str1.length();
        int l2 = str2.length();

        int[][] arr = new int[l1 + 1][l2 + 1];

        for (int i = l1 - 1; i >= 0; i--)
        {
            for (int j = l2 - 1; j >= 0; j--)
            {
                if (str1.charAt(i) == str2.charAt(j))
                    arr[i][j] = arr[i + 1][j + 1] + 1;
                else
                    arr[i][j] = Math.max(arr[i + 1][j], arr[i][j + 1]);
            }
        }

        int i = 0, j = 0;
        StringBuffer sb = new StringBuffer();
        while (i < l1 && j < l2)

 {
            if (str1.charAt(i) == str2.charAt(j))
            {
                sb.append(str1.charAt(i));
                i++;
                j++;
            }
            else if (arr[i + 1][j] >= arr[i][j + 1])
                i++;
            else
                j++;
        }
        return sb.toString();
    }

*/


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package codeforces_reloded;

import java.util.Scanner;

/**
 *
 * @author shubham
 */
public class B_310 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner s=new Scanner(System.in);

        int a=s.nextInt();
        String str="";
        for (int i = 0; i < a; i++) {
            str+=""+i;

        }
        int ar[]=new int[a];
        for (int i = 0; i < a; i++) {
            ar[i]=s.nextInt();

        }

        for (int j = 0; j < a; j++) {

        String str1="";
        for (int i = 0; i < a; i++) {

            if(i%2==0){
                if(ar[i]==a-1){
                    ar[i]=0;
                }
                else
                    ar[i]++;
            }
            else{
                if(ar[i]==0){
                    ar[i]=a-1;
                }
                else{
                    ar[i]--;
                }
            }
            str1+=ar[i];
        }

        if(str1.trim().equals(str.trim())){
            System.out.println("YES");
            return;
        }
        }

        System.out.println("NO");
    }

}


import java.util.Scanner;

/**
 * Created by yuu on 12/4/17.
 */
public class Problem556B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] gearsF = new int[n];
        for (int i = 0; i < n; i++) {
            gearsF[i] = sc.nextInt();
        }
        int forward = n - gearsF[n-1] - 1;

//        System.out.println(forward);
        for (int i = 0; i < n - 1; i++) {
            if ((n - 1 - i) % 2 == 1) {
                gearsF[i] -= forward;
                if (gearsF[i] < 0) {
                    gearsF[i] += n;
                }
            }
            else {
                gearsF[i] += forward;
                if (gearsF[i] >= n) {
                    gearsF[i] -= n;
                }
            }

//            for (int j = 0; j < n - 1; j++) {
//                System.out.print(gearsF[j] + " ");
//            }
//
//            System.out.println();
        }

//        for (int i = 0; i < n - 1; i++) {
//            System.out.print(gearsF[i] + " ");
//        }
//
//        System.out.println();

        // test
        boolean yes = true;

        for (int i = 0; i < n - 1; i++) {
            if (gearsF[i] != i) {
                yes = false;
                break;
            }
        }

        if (yes) System.out.println("Yes");
        else System.out.println("No");
    }
}


import java.util.*;
import java.io.*;
/**
 *
 * @author alanl
 */
public class Main{
    static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static void main(String[] args) throws IOException{
        int n = readInt(), arr[] = new int[n], sub[] = new int[n];
        for(int i = 0; i<n; i++){
            arr[i] = readInt();
            sub[i] = arr[i];
        }
        for(int i = 0; i<n; i++){
            Set<Integer>s = new HashSet();
            for(int j = 0; j<n; j++){
                if(j%2==0){
                    arr[j]++;
                }
                else arr[j]--;
                if(arr[j]==n)arr[j] = 0;
                else if(arr[j]<0)arr[j] = n-1;
                sub[j] = arr[j];
                s.add(arr[j]);
            }
            Arrays.sort(sub);
            if(Arrays.equals(sub, arr) && s.size()==n){
                println("Yes");
                return;
            }
        }
        println("No");
    }
    static String next () throws IOException {
        while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(input.readLine().trim());
        return st.nextToken();
    }
    static long readLong () throws IOException {
        return Long.parseLong(next());
    }
    static int readInt () throws IOException {
        return Integer.parseInt(next());
    }
    static double readDouble () throws IOException {
        return Double.parseDouble(next());
    }
    static char readChar () throws IOException {
        return next().charAt(0);
    }
    static String readLine () throws IOException {
        return input.readLine().trim();
    }
    static void print(Object b) {
        System.out.print(b);
    }
    static void println(Object b) {
        System.out.println(b);
    }
    static void println() {
        System.out.println();
    }
}


import java.util.*;
import java.io.*;
/**
 *
 * @author alanl
 */
public class Main{
    static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static void main(String[] args) throws IOException{
        int n = readInt(), arr[] = new int[n], sub[] = new int[n];
        for(int i = 0; i<n; i++){
            arr[i] = readInt();
            sub[i] = arr[i];
        }
        for(int i = 0; i<n; i++){
            for(int j = 0; j<n; j++){
                if(j%2==0){
                    arr[j]++;
                }
                else arr[j]--;
                if(arr[j]==n)arr[j] = 0;
                else if(arr[j]<0)arr[j] = n-1;
                sub[j] = arr[j];
            }
            Arrays.sort(sub);
            if(Arrays.equals(sub, arr)){
                println("Yes");
                return;
            }
        }
        println("No");
    }
    static String next () throws IOException {
        while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(input.readLine().trim());
        return st.nextToken();
    }
    static long readLong () throws IOException {
        return Long.parseLong(next());
    }
    static int readInt () throws IOException {
        return Integer.parseInt(next());
    }
    static double readDouble () throws IOException {
        return Double.parseDouble(next());
    }
    static char readChar () throws IOException {
        return next().charAt(0);
    }
    static String readLine () throws IOException {
        return input.readLine().trim();
    }
    static void print(Object b) {
        System.out.print(b);
    }
    static void println(Object b) {
        System.out.println(b);
    }
    static void println() {
        System.out.println();
    }
}


import java.util.*;
import java.io.*;
/**
 *
 * @author alanl
 */
public class Main{
    static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static void main(String[] args) throws IOException{
        int n = readInt(), arr[] = new int[n], sub[] = new int[n];
        for(int i = 0; i<n; i++){
            arr[i] = readInt();
            sub[i] = arr[i];
        }
        for(int i = 0; i<=n; i++){
            Set<Integer>s = new HashSet();
            for(int j = 0; j<n; j++){
                if(j%2==0){
                    arr[j]++;
                }
                else arr[j]--;
                if(arr[j]==n)arr[j] = 0;
                else if(arr[j]<0)arr[j] = n-1;
                s.add(arr[j]);
            }
            if(s.size()==n){
                println("Yes");
                return;
            }
        }
        println("No");
    }
    static String next () throws IOException {
        while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(input.readLine().trim());
        return st.nextToken();
    }
    static long readLong () throws IOException {
        return Long.parseLong(next());
    }
    static int readInt () throws IOException {
        return Integer.parseInt(next());
    }
    static double readDouble () throws IOException {
        return Double.parseDouble(next());
    }
    static char readChar () throws IOException {
        return next().charAt(0);
    }
    static String readLine () throws IOException {
        return input.readLine().trim();
    }
    static void print(Object b) {
        System.out.print(b);
    }
    static void println(Object b) {
        System.out.println(b);
    }
    static void println() {
        System.out.println();
    }
}


import java.util.*;
import java.io.BufferedReader;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class asd
{
    public static void main(String [] args) throws IOException
    {
        Reader.init(System.in);
        int N = Reader.nextInt();
        int[] numbers = new int[N];
        int[] answer = new int[N];
        for (int i=0; i<N; i++)
        {
            numbers[i] = Reader.nextInt();
            answer[i] = i;
        }
        boolean yes = false;
        boolean contin = true;
        for(int i=0; i<N; i++)
        {
            if (numbers[0] == answer[0])
            {
                contin = true;
                for(int d=1; d<N && contin; d++)
                {

                    if (numbers[d] != answer[d])
                    {
                        contin = false;
                    }
                }
                if (contin)
                {
                    yes = true;
                }
            }
            else
            {
                for(int c=0; c<N; c++)
                {
                    if (c%2 ==0)
                    {
                        numbers[c]++;
                        if(numbers[c] == N)
                        {
                            numbers[c] = 0;
                        }
                    }
                    else
                    {
                        numbers[c]--;
                        if (numbers[c] == -1)
                        {
                            numbers[c] = N-1;
                        }
                    }
                }
            }
        }

        if(yes)
        {
            System.out.println("Yes");

        }
        else
        {
            System.out.println("No");
        }
    }
}
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

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

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}


import java.util.*;
import java.io.BufferedReader;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class dsfwet
{
    public static void main(String [] args) throws IOException
    {
        Reader.init(System.in);
        int N = Reader.nextInt();
        String answer = "";
        int[] ints = new int[N];
        String[] parts = new String[N-1];
        boolean yes = false;
        String test= "";
        for(int i=0; i<N; i++)
        {
            ints[i] = Reader.nextInt();
            answer+=Integer.toString(i);
            test+=Integer.toString(ints[i]);
        }
        if (test.equals(answer))
        {
            System.out.println("Yes");
        }
        else
        {
        for (int n=0; n<N-1; n++)
        {
            parts[n] = "";
            for (int i=0; i<N; i++)
            {
                if (i %2 == 0)
                {
                    ints[i]++;
                    if (ints[i] == N)
                    {
                        ints[i] = 0;
                    }
                    parts[n]+=Integer.toString(ints[i]);
                }
                else
                {
                    ints[i]--;
                    if (ints[i] == -1)
                    {
                        ints[i] = N-1;
                    }
                    parts[n]+=Integer.toString(ints[i]);
                }
            }

        }
        for (int i=0; i<N-1; i++)
        {
            if (parts[i].equals(answer))
            {
                yes = true;
            }
        }

        if (yes)
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
    }
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

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

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}


import java.util.*;
import java.io.BufferedReader;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class dsfwet
{
    public static void main(String [] args) throws IOException
    {
        Reader.init(System.in);
        int N = Reader.nextInt();
        String answer = "";
        int[] ints = new int[N];
        String[] parts = new String[N-1];
        boolean yes = false;

        for(int i=0; i<N; i++)
        {
            ints[i] = Reader.nextInt();
            answer+=Integer.toString(i);
        }
        for (int n=0; n<N-1; n++)
        {
            parts[n] = "";
            for (int i=0; i<N; i++)
            {
                if (i %2 == 0)
                {
                    ints[i]++;
                    if (ints[i] == N)
                    {
                        ints[i] = 0;
                    }
                    parts[n]+=Integer.toString(ints[i]);
                }
                else
                {
                    ints[i]--;
                    if (ints[i] == -1)
                    {
                        ints[i] = N-1;
                    }
                    parts[n]+=Integer.toString(ints[i]);
                }
            }

        }
        for (int i=0; i<N-1; i++)
        {
            if (parts[i].equals(answer))
            {
                yes = true;
            }
        }

        if (yes)
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

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

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}


import java.util.Scanner;

public class Main {

		public static void main(String[] args) {

			Scanner IN = new Scanner(System.in);

			int n=IN.nextInt();
			int b=IN.nextInt();
			int cont=0,f;
			while (n-->0)
			{
			int c=IN.nextInt();
			cont=cont+c;

			}
			if (cont<0)
			{
				int t=cont/b;
				f = cont/b;
				int r=t+f;
				System.out.print(r/n);
			}

		}
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int n=Integer.parseInt(s.nextLine());
		String in[]=s.nextLine().split(" ");
		int i[]=new int[n];
		for(int a=1;a<=n;a++){
			i[a-1]=Integer.parseInt(in[a-1]);

		}
			int flag=0;
		for(int c=1;c<=n;c++)
		{
			int count=0;
			for(int b=0;b<n;b++)
				{
					if(i[b]==b)
					{
					count++;
					}
				}
				if(count==n){flag=1;
				{
					System.out.println("YES");
					break;
				}
				}
				else
				{
					for(int a=1;a<=n;a++)
					{
						if(a%2==0)
							if(i[a-1]==0)
								i[a-1]=n-1;
							else
								i[a-1]--;
						else{
								if(i[a-1]==n-1)
									i[a-1]=0;
								else
									i[a-1]++;
							}
					}
				}
			}
			if(flag==0)
				System.out.println("NO");
		}
}


import java.util.Scanner;
public class test{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int i=0,n=sc.nextInt();
        int[] a=new int[n];
        int[] b=new int[n];
        for(;i<n;i++){
            a[i]=sc.nextInt();
            b[i]=a[i];
        }
        while(true){
            if(isReal(a)){
                System.out.println("Real");
                break;
            }
            for(i=0;i<n;i+=2){
                a[i]+=1;
                a[i]%=n;
            }
            for(i=1;i<n;i+=2){
                a[i]+=1;
                a[i]%=n;
            }
            if(isFake(a,b)){
                System.out.println("Fake");
                break;
            }
        }
    }
    private boolean isReal(int[] a){
        for(int i=0;i<a.length;i++)
            if(a[i]!=i)return false;
        return true;
    }
    private boolean isFake(int[] a,int[] b){
        for(int i=0;i<a.length;i++)
            if(a[i]!=b[i])return false;
        return true;
    }
}


import java.util.Scanner;
public class test{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int i=0,n=sc.nextInt();
        int[] a=new int[n];
        int[] b=new int[n];
        for(;i<n;i++){
            a[i]=sc.nextInt();
            b[i]=a[i];
        }
        while(true){
            if(isReal(a)){
                System.out.println("Yes");
                break;
            }
            for(i=0;i<n;i+=2){
                a[i]+=1;
                a[i]%=n;
            }
            for(i=1;i<n;i+=2){
                a[i]-=1;
                if(a[i]<0)a[i]=n-1;
            }
            if(isFake(a,b)){
                System.out.println("No");
                break;
            }
        }
    }
    private static boolean isReal(int[] a){
        for(int i=0;i<a.length;i++)
            if(a[i]!=i)return false;
        return true;
    }
    private static boolean isFake(int[] a,int[] b){
        for(int i=0;i<a.length;i++)
            if(a[i]!=b[i])return false;
        return true;
    }
}


import java.util.Scanner;
public class test{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int i=0,n=sc.nextInt();
        int[] a=new int[n];
        int[] b=new int[n];
        for(;i<n;i++){
            a[i]=sc.nextInt();
            b[i]=a[i];
        }
        while(true){
            if(isReal(a)){
                System.out.println("Real");
                break;
            }
            for(i=0;i<n;i+=2){
                a[i]+=1;
                a[i]%=n;
            }
            for(i=1;i<n;i+=2){
                a[i]-=1;
                if(a[i]<0)a[i]=n-1;
            }
            if(isFake(a,b)){
                System.out.println("Fake");
                break;
            }
        }
    }
    private static boolean isReal(int[] a){
        for(int i=0;i<a.length;i++)
            if(a[i]!=i)return false;
        return true;
    }
    private static boolean isFake(int[] a,int[] b){
        for(int i=0;i<a.length;i++)
            if(a[i]!=b[i])return false;
        return true;
    }
}


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

/**
 * @author Deepit-PC
 *
 */
public class CaseOfFakeNumbers {
    public static InputReader in;
    public static PrintWriter out;

    public static final int MOD = (int) (1e9 + 7);

    public static void main(String[] args) {
	in = new InputReader(System.in);
	out = new PrintWriter(System.out);

	int n = in.nextInt();
	String result = "No";
	int[] a = in.nextIntArray(n);
	for (int steps = 0; steps < n + 5; steps++) {
	    for (int i = 0; i < n; i++) {
		if((i&1) == 0) {
		    a[i]++;
		    if(a[i] == n) {
			a[i] = 0;
		    }
		} else {
		    a[i]--;
		    if(a[i] == -1) {
			a[i] = n - 1;
		    }
		}
	    }
	    boolean found = true;
	    for (int i = 0; i < n; i++) {
		found &= (a[i] != i);
	    }
	    if(found) {
		result = "Yes";
		break;
	    }
	}
	out.println(result);

	out.close();
    }

    static class Node implements Comparable<Node> {
	int next;
	int dist;

	public Node(int u, int v) {
	    this.next = u;
	    this.dist = v;
	}

	public void print() {
	    out.println(next + " " + dist + " ");
	}

	public int compareTo(Node that) {
	    return Integer.compare(this.next, that.next);
	}
    }

    static class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[8192];
	private int curChar, snumChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
	    this.stream = stream;
	}

	public int snext() {
	    if (snumChars == -1)
		throw new InputMismatchException();
	    if (curChar >= snumChars) {
		curChar = 0;
		try {
		    snumChars = stream.read(buf);
		} catch (IOException e) {
		    throw new InputMismatchException();
		}
		if (snumChars <= 0)
		    return -1;
	    }
	    return buf[curChar++];
	}

	public int nextInt() {
	    int c = snext();
	    while (isSpaceChar(c))
		c = snext();
	    int sgn = 1;
	    if (c == '-') {
		sgn = -1;
		c = snext();
	    }
	    int res = 0;
	    do {
		if (c < '0' || c > '9')
		    throw new InputMismatchException();
		res *= 10;
		res += c - '0';
		c = snext();
	    } while (!isSpaceChar(c));
	    return res * sgn;
	}

	public long nextLong() {
	    int c = snext();
	    while (isSpaceChar(c))
		c = snext();
	    int sgn = 1;
	    if (c == '-') {
		sgn = -1;
		c = snext();
	    }
	    long res = 0;
	    do {
		if (c < '0' || c > '9')
		    throw new InputMismatchException();
		res *= 10;
		res += c - '0';
		c = snext();
	    } while (!isSpaceChar(c));
	    return res * sgn;
	}

	public int[] nextIntArray(int n) {
	    int a[] = new int[n];
	    for (int i = 0; i < n; i++)
		a[i] = nextInt();
	    return a;
	}

	public String readString() {
	    int c = snext();
	    while (isSpaceChar(c))
		c = snext();
	    StringBuilder res = new StringBuilder();
	    do {
		res.appendCodePoint(c);
		c = snext();
	    } while (!isSpaceChar(c));
	    return res.toString();
	}

	public boolean isSpaceChar(int c) {
	    if (filter != null)
		return filter.isSpaceChar(c);
	    return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public interface SpaceCharFilter {
	    public boolean isSpaceChar(int ch);
	}
    }
}


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

/**
 * @author Deepit-PC
 *
 */
public class CaseOfFakeNumbers {
    public static InputReader in;
    public static PrintWriter out;

    public static final int MOD = (int) (1e9 + 7);

    public static void main(String[] args) {
	in = new InputReader(System.in);
	out = new PrintWriter(System.out);

	int n = in.nextInt();
	String result = "No";
	int[] a = in.nextIntArray(n);
	for (int steps = 0; steps <= n; steps++) {
	    for (int i = 0; i < n; i++) {
		if((i&1) == 0) {
		    a[i]++;
		    if(a[i] == n) {
			a[i] = 0;
		    }
		} else {
		    a[i]--;
		    if(a[i] == -1) {
			a[i] = n - 1;
		    }
		}
	    }
	    boolean found = true;
	    for (int i = 0; i < n; i++) {
		found &= (a[i] == i);
	    }
	    if(found) {
		result = "Yes";
		break;
	    }
	}
	out.println(result);

	out.close();
    }

    static class Node implements Comparable<Node> {
	int next;
	int dist;

	public Node(int u, int v) {
	    this.next = u;
	    this.dist = v;
	}

	public void print() {
	    out.println(next + " " + dist + " ");
	}

	public int compareTo(Node that) {
	    return Integer.compare(this.next, that.next);
	}
    }

    static class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[8192];
	private int curChar, snumChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
	    this.stream = stream;
	}

	public int snext() {
	    if (snumChars == -1)
		throw new InputMismatchException();
	    if (curChar >= snumChars) {
		curChar = 0;
		try {
		    snumChars = stream.read(buf);
		} catch (IOException e) {
		    throw new InputMismatchException();
		}
		if (snumChars <= 0)
		    return -1;
	    }
	    return buf[curChar++];
	}

	public int nextInt() {
	    int c = snext();
	    while (isSpaceChar(c))
		c = snext();
	    int sgn = 1;
	    if (c == '-') {
		sgn = -1;
		c = snext();
	    }
	    int res = 0;
	    do {
		if (c < '0' || c > '9')
		    throw new InputMismatchException();
		res *= 10;
		res += c - '0';
		c = snext();
	    } while (!isSpaceChar(c));
	    return res * sgn;
	}

	public long nextLong() {
	    int c = snext();
	    while (isSpaceChar(c))
		c = snext();
	    int sgn = 1;
	    if (c == '-') {
		sgn = -1;
		c = snext();
	    }
	    long res = 0;
	    do {
		if (c < '0' || c > '9')
		    throw new InputMismatchException();
		res *= 10;
		res += c - '0';
		c = snext();
	    } while (!isSpaceChar(c));
	    return res * sgn;
	}

	public int[] nextIntArray(int n) {
	    int a[] = new int[n];
	    for (int i = 0; i < n; i++)
		a[i] = nextInt();
	    return a;
	}

	public String readString() {
	    int c = snext();
	    while (isSpaceChar(c))
		c = snext();
	    StringBuilder res = new StringBuilder();
	    do {
		res.appendCodePoint(c);
		c = snext();
	    } while (!isSpaceChar(c));
	    return res.toString();
	}

	public boolean isSpaceChar(int c) {
	    if (filter != null)
		return filter.isSpaceChar(c);
	    return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public interface SpaceCharFilter {
	    public boolean isSpaceChar(int ch);
	}
    }
}


import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n;
		boolean check=true;
		n=scan.nextInt();
		int[] list = new int[n];
		for(int i=0;i<n;i++){
			list[i]=scan.nextInt();
		}
		while(list[0]!=0){
			for(int i=0;i<n;i++){
				list[i]=(list[i]+(int)Math.pow(-1, i))%n;
			}
		}
		for(int i=0;i<n-1;i++){
			if((list[i]+1)!=list[i+1]){
				check=false;
				break;
			}
		}

		if(check) System.out.println("Yes");
		else System.out.println("No");

	    scan.close();
	}
}


import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n;
		boolean check=true;
		n=scan.nextInt();
		int[] list = new int[n];
		for(int i=0;i<n;i++){
			list[i]=scan.nextInt();
		}
		while(list[0]!=0){
			for(int i=0;i<n;i++){
				list[i]=(n+list[i]+(int)Math.pow(-1, i))%n;
			}
		}
		for(int i=0;i<n-1;i++){
			if((list[i]+1)!=list[i+1]){
				check=false;
				break;
			}
		}

		if(check) System.out.println("Yes");
		else System.out.println("No");

	    scan.close();
	}
}


/*
Keep solving problems.
*/

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

public class CFA {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    private static final long MOD = 1000 * 1000 * 1000 + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};
    private static final String yes = "Yes";
    private static final String no = "No";

    void solve() throws IOException {
        int n = nextInt();
        int[] arr = nextIntArr(n);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                arr[j] = findNext(arr[j], j % 2 == 0 ? 1 : -1, n);
            }

            boolean valid = true;
            for (int j = 0; j < n; j++) {
                if (j != arr[j]) {
                    valid = false;
                    break;
                }
            }

            if (valid) {
                outln(yes);
                return;
            }
        }

        outln(no);
    }

    int findNext(int cur, int clock, int n) {
        cur += clock;
        while (cur >= n) {
            cur -= n;
        }
        while (cur < 0) {
            cur += n;
        }

        return cur;
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }

    long gcd(long a, long b) {
        while(a != 0 && b != 0) {
            long c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }

    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    private void formatPrint(double val) {
        System.out.format("%.9f%n", val);
    }
    public CFA() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFA();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


import java.util.Scanner;

public class FakeNumbers {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] arr = new int[n];
		for(int i=0; i<n;i++){
			arr[i] = input.nextInt();
		}
		//for(int i=)
	    for(int i=0; i<n;i++){
	    	if(check(arr)){
	    		System.out.println("Yes");
	    		return;
	    	}
	    	rotate(arr);
	    }
	    System.out.println("No");
	}

	private static boolean check(int[] arr){
		for(int i=0; i<arr.length;i++){
			if(arr[i]!=i)return false;
		}
		return true;
	}

	private static void rotate(int[] arr){
		for(int i=0; i<arr.length;i++){
			if(i%2==0){
				if(arr[i]==arr.length-1)arr[i]=0;
				else
					arr[i]=arr[i]+1;
			}
			else{
				if(arr[i]==0)arr[i] = arr.length-1;
				else
					arr[i] = arr[i]-1;
			}
		}
	}

}


import java.util.Scanner;

/**
 * Created by Majid on 6/24/2015.
 */
public class B {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int delta = n - input.nextInt();

        for (int i = 1; i < n; i++) {
            if (i % 2 == 1) {
                if (input.nextInt() != ((i + delta) % n)) {
                    System.out.println("No");
                    System.exit(0);
                }
            } else {
                if (input.nextInt() != ((i - delta) < 0 ? (i - delta + n) : (i - delta))) {
                    System.out.println("No");
                    System.exit(0);
                }
            }
        }
        System.out.println("Yes");
    }
}


import java.util.Scanner;

/**
 * Created by Majid on 6/24/2015.
 */
public class B {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int delta = n - input.nextInt();

        for (int i = 1; i < n; i++) {
            if (i % 2 == 1) {
                if (input.nextInt() != ((i + delta) % n)) {
                    System.out.println("No");
                    System.exit(0);
                }
            } else {
                if (input.nextInt() != ((i - delta) % n)) {
                    System.out.println("No");
                    System.exit(0);
                }
            }
        }
        System.out.println("Yes");
    }
}


import java.util.Scanner;

/**
 * Created by Majid on 6/24/2015.
 */
public class B {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int delta = (n - input.nextInt()) % n;

        for (int i = 1; i < n; i++) {
            if (i % 2 == 1) {
                if (input.nextInt() != ((i + delta) % n)) {
                    System.out.println("No");
                    System.exit(0);
                }
            } else {
                if (input.nextInt() != ((i - delta) % n)) {
                    System.out.println("No");
                    System.exit(0);
                }
            }
        }
        System.out.println("Yes");
    }
}


import java.util.Scanner;

/**
 * Created by Majid on 6/24/2015.
 */
public class B {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int delta = n - input.nextInt();

        for (int i = 1; i < n; i++) {
            if (i % 2 == 1) {
                if (input.nextInt() != ((i + delta) % n)) {
                    System.out.println("No");
                    System.exit(0);
                }
            } else {
                if (input.nextInt() != ((i - delta) % n)) {
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
    }
}


import java.util.Scanner;

/**
 * Created by Majid on 6/24/2015.
 */
public class B {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int delta = n - input.nextInt();

        for (int i = 1; i < n; i++) {
            if (i % 2 == 1) {
                if (input.nextInt() != ((i + delta) % n)) {
                    System.out.println("No");
                    System.exit(0);
                }
            } else {
                if (input.nextInt() != ((i + delta) % n)) {
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
    }
}


import java.util.Scanner;

/**
 * Created by Majid on 6/24/2015.
 */
public class B {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int delta = n - input.nextInt();
        delta = delta < 0 ? delta + n : delta;

        for (int i = 1; i < n; i++) {
            if (i % 2 == 1) {
                if (input.nextInt() != ((i + delta) % n)) {
                    System.out.println("No");
                    System.exit(0);
                }
            } else {
                if (input.nextInt() != (((i - delta) % n) > 0 ? ((i - delta) % n) : (n + ((i - delta) % n)))) {
                    System.out.println("No");
                    System.exit(0);
                }
            }
        }
        System.out.println("Yes");
    }
}


import static java.lang.Math.max;

import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class B implements Runnable {

    final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    final static String fileName = "";

    void init() throws IOException {
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    public static void main(String[] args) {
        new B().run();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws NumberFormatException, IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws NumberFormatException, IOException {
        return Long.parseLong(readString());
    }

    int[] readIntArray(int size) throws NumberFormatException, IOException {
        int[] arr = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i] = readInt();
        }
        return arr;
    }

    static long timeIn;

    void time() {
        System.err.println("Time = " + (System.currentTimeMillis() - timeIn));
    }

    @Override
    public void run() {
        try {
            timeIn = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private void solve() throws IllegalArgumentException, IOException {
        int n = readInt();
        int[] arr = readIntArray(n);

        int prev = -1;

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                int cur = arr[i] > i ? i + n - arr[i] : i - arr[i];
                if (prev > -1) {
                    if (prev != cur) {
                        out.println("No");
                        return;
                    }
                }
                prev = cur;
            } else {
                int cur = arr[i] >= i ? arr[i] - i : arr[i] + n - i;
                if (prev > -1) {
                    if (prev != cur) {
                        out.println("No");
                        return;
                    }
                }
                prev = cur;
            }
        }

        out.println("Yes");
    }

}


import static java.lang.Math.max;

import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class B implements Runnable {

    final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    final static String fileName = "";

    void init() throws IOException {
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    public static void main(String[] args) {
        new B().run();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws NumberFormatException, IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws NumberFormatException, IOException {
        return Long.parseLong(readString());
    }

    int[] readIntArray(int size) throws NumberFormatException, IOException {
        int[] arr = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i] = readInt();
        }
        return arr;
    }

    static long timeIn;

    void time() {
        System.err.println("Time = " + (System.currentTimeMillis() - timeIn));
    }

    @Override
    public void run() {
        try {
            timeIn = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private void solve() throws IllegalArgumentException, IOException {
        int n = readInt();
        int[] arr = readIntArray(n);

        int prev = -1;

        for (int i = 0; i < n; i++) {
            if (i % 2 == 1) {
                int cur = arr[i] > i ? i + n - arr[i] : i - arr[i];
                if (prev > -1) {
                    if (prev != cur) {
                        out.println("No");
                        return;
                    }
                }
                prev = cur;
            } else {
                int cur = arr[i] > i ? arr[i] - i : arr[i] + n - i;
                if (prev > -1) {
                    if (prev != cur) {
                        out.println("No");
                        return;
                    }
                }
                prev = cur;
            }
        }

        out.println("Yes");
    }

}


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

public class Main
{
    public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int n = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        int a = Integer.parseInt(st.nextToken());
        int rot = n - a;
        for (int i = 1; i < n; i++)
        {
            a = Integer.parseInt(st.nextToken());
            a = (a + (i % 2 == 1? n - rot : rot)) % n;

            if (a != i)
            {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.NoSuchElementException;
import java.util.Objects;

public class CaseOfFakeNumbers {

    public static void main(String[] args) {
        Reader read = new Reader();

        int n = read.nextInt();
        int[] gears = new int[n];

        for(int i=0; i<gears.length; i++)
            gears[i] = read.nextInt();

        int i = 0;
        boolean found = isFound(gears, n);

        while(i < n-1 && !found) {
            for(int j=0; j<n; j++) {
                if((j & 1) == 0) {
                    gears[j] = (gears[j] + 1) % n;
                } else {
                    gears[j] = gears[j] == 0
                            ? n-1
                            : gears[j] - 1;
                }
            }
            found = isFound(gears, n);
            i++;
        }

        if(found)
            System.out.print("Yes");
        else
            System.out.print("No");
    }

    private static boolean isFound(int[] gears, int n) {
        if(gears[0] != 0 || gears[n-1] != n-1)
            return false;

        int i = 1;
        while(i < gears.length && gears[i-1]+1 == gears[i])
            i++;

        return i == gears.length;
    }

    private static class Reader {

        private final BufferedReader reader;
        private final String separator;
        private String ln;
        private String[] tokens;
        private int ptr;

        Reader(String separator, InputStream input) {
            this.reader = new BufferedReader(new InputStreamReader(input));
            this.separator = separator;
            this.ptr = -1;
        }

        Reader(String separator) { this(separator, System.in); }

        Reader() { this(" "); }

        String nextStr(){
            if (Objects.isNull(ln)) {
                try {
                    ln = reader.readLine();
                } catch (IOException e) {
                    System.out.println(e.getMessage());
                }
                if (Objects.nonNull(ln)) {
                    tokens = ln.split(separator);
                    ptr = 0;
                } else {
                    throw new NoSuchElementException("no next element");
                }

            } else if (ptr == tokens.length) {
                ln = null;
                tokens = null;
                ptr = -1;
                return nextStr();
            }

            return tokens[ptr++];
        }

        int nextInt() { return Integer.parseInt(nextStr()); }

        long nextLong() { return Long.parseLong(nextStr()); }

        double nextDouble() { return Double.parseDouble(nextStr()); }
    }
}


import java.util.Scanner;

/**
 * Created by Rahul on 31-08-2017.
 */
public class CaseOfFakeNumber {
    public static  void main(String args[]){
        Scanner S=new Scanner(System.in);
        int n=S.nextInt();
        int []number=new int [n];
        int []checkNumber=new int [n];
        for(int i=0;i<number.length;i++){
            number[i]=S.nextInt();
            checkNumber[i]=number[i];
        }
        int [ ]nm=new int [n];
        for(int i=0;i<nm.length;i++)
            nm[i]=i;
        int k1=0,check1=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<checkNumber.length;j++){
                int k=j+1;
                if(k%2!=0){
                    checkNumber[j]+=1;
                    if(checkNumber[j]>n-1)
                        checkNumber[j]=0;
                }
                else
                {     checkNumber[j]-=1;
                    if(checkNumber[j]==-1)
                        checkNumber[j]=n-1;
                }
              if(nm[j]==checkNumber[j])
                  k1++;
            }
            if(k1==n)
                check1=1;
            else
                k1=0;
        }
        int check=0;

        if(check1==1)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


//package CodeForces;

import java.util.Scanner;

public class CaseOfFakeNumbers {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int arr[] = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		int nSteps = (N - arr[0]) % N;
		System.out.println(arr[0]+" "+nSteps);
		for (int i = 1; i < N; i++) {
			if(i%2 != 0) {
				if((arr[i] + (N - nSteps))%N != i) {
					System.out.println("NO");
					return;
				}
			} else if(i%2 == 0) {
				if((arr[i] + nSteps)%N != i) {
					System.out.println("NO");
					return;
				}
			}
		}
		System.out.println("YES");
	}
}


//package CodeForces;

import java.util.Scanner;

public class CaseOfFakeNumbers {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int arr[] = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		int nSteps = (N - arr[0]) % N;
		System.out.println(arr[0]+" "+nSteps);
		for (int i = 1; i < N; i++) {
			if(i%2 != 0) {
				if((arr[i] + (N - nSteps))%N != i) {
					System.out.println("No");
					return;
				}
			} else if(i%2 == 0) {
				if((arr[i] + nSteps)%N != i) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


//package CodeForces;

import java.util.Scanner;

public class CaseOfFakeNumbers {
	static String str = "", real = "";

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int arr[] = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
			str += arr[i];
			real += i;
		}

		if (str.equals(real)) {
			System.out.println("Yes");
			return;
		}

		while (true) {
			String tempStr = "";
			for (int i = 0; i < N; i++) {
				if (i % 2 == 0) {
					int temp = arr[i] + 1;
					if (temp >= N) {
						arr[i] = 0;
					} else {
						arr[i] = temp;
					}
				} else {
					int temp = arr[i] - 1;
					if (temp < 0) {
						arr[i] = N - 1;
					} else {
						arr[i] = temp;
					}
				}
				tempStr += arr[i];
			}
			if (tempStr.equals(real)) {
				System.out.println("Yes");
				break;
			} else if (tempStr.equals(str)) {
				System.out.println("No");
				break;
			}
		}
	}
}


//package CodeForces;

import java.util.Scanner;

public class CaseOfFakeNumbers {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int arr[] = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		int nSteps = (N - arr[0]) % N;
		for (int i = 1; i < N; i++) {
			if(i%2 != 0) {
				if((arr[i] + (N - nSteps))%N != i) {
					System.out.println("No");
					return;
				}
			} else if(i%2 == 0) {
				if((arr[i] + nSteps)%N != i) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


//package CodeForces;

import java.util.Scanner;

public class CaseOfFakeNumbers {
	static String str = "", real = "";

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int arr[] = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
			str += arr[i];
			real += i;
		}
		if(currentSequence(arr, N).equals(real)) {
			System.out.println("Yes");
			return;
		}

		while (true) {
			for (int i = 0; i < N; i++) {
				if (i % 2 == 0) {
					int temp = arr[i] + 1;
					if (temp >= N) {
						arr[i] = 0;
					} else {
						arr[i] = temp;
					}
				} else {
					int temp = arr[i] - 1;
					if (temp < 0) {
						arr[i] = N - 1;
					} else {
						arr[i] = temp;
					}
				}
			}
			String tempStr = currentSequence(arr, N);
			if (tempStr.equals(real)) {
				System.out.println("Yes");
				break;
			} else if (tempStr.equals(str)) {
				System.out.println("No");
				break;
			}
		}
	}

	private static String currentSequence(int[] arr, int N) {
		String tmpStr = "";
		for (int i = 0; i < N; i++) {
			tmpStr += arr[i];
		}
		return tmpStr;
	}
}


//package CodeForces;

import java.util.Scanner;

public class CaseOfFakeNumbers {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int arr[] = new int[N];
		String str = "", real = "";
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
			str += arr[i];
			real += i;
		}
		while (true) {
			for (int i = 0; i < N; i++) {
				if (i % 2 == 0) {
					int temp = arr[i] + 1;
					if (temp >= N) {
						arr[i] = 0;
					} else {
						arr[i] = temp;
					}
				} else {
					int temp = arr[i] - 1;
					if (temp < 0) {
						arr[i] = N - 1;
					} else {
						arr[i] = temp;
					}
				}
			}
			if(currentSequence(arr, N).equals(str)) {
				System.out.println("NO");
				break;
			} else if(currentSequence(arr, N).equals(real)) {
				System.out.println("YES");
				break;
			}
		}
	}

	private static String currentSequence(int[] arr, int N) {
		String tmpStr = "";
		for (int i = 0; i < N; i++) {
			tmpStr += arr[i];
		}
		return tmpStr;
	}
}


//package CodeForces;

import java.util.Scanner;

public class CaseOfFakeNumbers {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int arr[] = new int[N];
		String str = "", real = "";
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
			str += arr[i];
			real += i;
		}
		while (true) {
			if(currentSequence(arr, N).equals(real)) {
				System.out.println("YES");
				break;
			}
			for (int i = 0; i < N; i++) {
				if (i % 2 == 0) {
					int temp = arr[i] + 1;
					if (temp >= N) {
						arr[i] = 0;
					} else {
						arr[i] = temp;
					}
				} else {
					int temp = arr[i] - 1;
					if (temp < 0) {
						arr[i] = N - 1;
					} else {
						arr[i] = temp;
					}
				}
			}
			if(currentSequence(arr, N).equals(str)) {
				System.out.println("NO");
				break;
			}
		}
	}

	private static String currentSequence(int[] arr, int N) {
		String tmpStr = "";
		for (int i = 0; i < N; i++) {
			tmpStr += arr[i];
		}
		return tmpStr;
	}
}


//package p556B;

import java.util.Arrays;
import java.util.Scanner;

public class CaseOfFakeNumbers {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n;

		n = sc.nextInt();
		int sequence[] = new int[n]; // A set of numbers that is a ascending order.
		int digits[] = new int[n]; // input data, the sequence of active teeth.

		// setting the numbers in a ascending order and input the tooth of the i-th gear.
		for(int i=0; i<n; i++)
		{
			sequence[i] = i;
			digits[i] = sc.nextInt();
		}

		if(isThePuzzleReal(sequence, digits)) System.out.println("Yes");
		else System.out.println("No");

	}

	public static boolean isThePuzzleReal(int[] sequence, int[] digits)
	{
		int loop = digits.length;

		for(int i=0; i<loop; i++)
		{
			for(int j=0; j<loop; j++)
			{
				if(j%2 == 0) // even index, clockwise rotation
					digits[j] = (digits[j]+1)%loop;
				else // odd index, counter-clockwise rotation
					digits[j] = (digits[j]-1 < 0)? loop-1 : digits[j]-1;
			}

			if(Arrays.equals(sequence, digits)) return true;
		}

		return false;
	}
}


//package p556B;

import java.util.Arrays;
import java.util.Scanner;

public class CaseOfFakeNumbers {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n;

		n = sc.nextInt();
		int sequence[] = new int[n]; // A set of numbers that is a ascending order.
		int digits[] = new int[n]; // input data, the sequence of active teeth.

		// setting the numbers in a ascending order and input the tooth of the i-th gear.
		for(int i=0; i<n; i++)
		{
			sequence[i] = i;
			digits[i] = sc.nextInt();
		}

		if(isThePuzzleReal(sequence, digits)) System.out.println("Yes");
		else System.out.println("No");

	}

	public static boolean isThePuzzleReal(int[] sequence, int[] digits)
	{
		int loop = digits.length;

		for(int i=0; i<loop-1; i++)
		{
			for(int j=0; j<loop; j++)
			{
				if(j%2 == 0) // even index, clockwise rotation
					digits[j] = (digits[j]+1)%loop;
				else // odd index, counter-clockwise rotation
					digits[j] = (digits[j]-1 < 0)? loop-1 : digits[j]-1;
			}

			if(Arrays.equals(sequence, digits)) return true;
		}

		return false;
	}
}


// Working program with FastReader
import static java.lang.System.out;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class cf_556b{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args)
    {
        FastReader s=new FastReader();
        int n = s.nextInt();
        boolean found = true;
        int f = s.nextInt();
        int turn = (n - f)%n;
        for(int i = 1; i <n; i++){
            f = s.nextInt();
            if(i%2==1){
                if(i!=((f+n-turn)%n)) {found=false; break;}
            }
            else{
                if(i!=((f+turn)%n)) {found=false; break;}
            }
        }//for
        if(found) out.println("Yes");
        else out.println("No");
    } //main
} //contest


import java.util.Scanner;

public class B {

    static int N;
    static int mas [] = new int [ 1000 ];

    public static void main(String[] args) {

        int flag = 0;
        Scanner sc = new Scanner (  System.in );

        N = sc.nextInt ();
        for ( int i = 0 ; i < N ;++i ) {
            mas [ i ] = sc.nextInt ();
        }

        if ( N == 1 ) {
            System.out.println ( "Yes" );
            System.exit ( 0 );
        }

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

            for ( int j = 0 ; j < N ; ++j  ) {
                if ( j % 2 == 0 ) {
                    mas [ j ] ++;
                    if ( mas [ j ] == N ) mas [ j ] = 0;
                }
                else {
                    mas [ j ] --;
                    if ( mas [ j ] == - 1 ) mas [ j ] = N - 1;
                }

            }

            for ( int j = 1 ; j < N ; ++j ) {
                if ( mas [ j ] == mas [ j - 1 ] + 1 ) {
                    flag = 1;
                    continue;
                }
                else {
                    flag = 0;
                    break;
                }
            }

            if ( flag == 1 ) {
                System.out.println ( "Yes" );
                System.exit ( 0 );
            }
        }

        System.out.println ( "No" );

    }
}


import java.util.Scanner;

public class B {

    static int N;
    static int mas [] = new int [ 1000 ];

    public static void main(String[] args) {

        int flag = 0;
        Scanner sc = new Scanner (  System.in );

        N = sc.nextInt ();
        for ( int i = 0 ; i < N ;++i ) {
            mas [ i ] = sc.nextInt ();
        }

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

            for ( int j = 0 ; j < N ; ++j  ) {
                if ( j % 2 == 0 ) {
                    mas [ j ] ++;
                    if ( mas [ j ] == N ) mas [ j ] = 0;
                }
                else {
                    mas [ j ] --;
                    if ( mas [ j ] == - 1 ) mas [ j ] = N - 1;
                }

            }

            for ( int j = 1 ; j < N ; ++j ) {
                if ( mas [ j ] == mas [ j - 1 ] + 1 ) {
                    flag = 1;
                    continue;
                }
                else {
                    flag = 0;
                    break;
                }
            }

            if ( flag == 1 ) {
                System.out.println ( "Yes" );
                System.exit ( 0 );
            }
        }

        System.out.println ( "No" );

    }
}


import java.util.Scanner;

public class B {

    static int N;
    static int mas [] = new int [ 1000 ];

    public static void main(String[] args) {

        int flag = 2;
        Scanner sc = new Scanner (  System.in );

        N = sc.nextInt ();
        for ( int i = 0 ; i < N ;++i ) {
            mas [ i ] = sc.nextInt ();
        }

        if ( N == 1 ) {
            System.out.println ( "Yes" );
            System.exit ( 0 );
        }

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

            for ( int j = 0 ; j < N ; ++j  ) {
                if ( j % 2 == 0 ) {
                    mas [ j ] ++;
                    if ( mas [ j ] == N ) mas [ j ] = 0;
                }
                else {
                    mas [ j ] --;
                    if ( mas [ j ] == - 1 ) mas [ j ] = N - 1;
                }

                if ( j >= 1 ) {
                    if ( mas [ j ] == mas [ j - 1 ] + 1 && flag != 0 ) flag = 1;
                    else flag = 0;
                }

            }

            if ( flag == 1 ) {
                System.out.println ( "Yes" );
                System.exit ( 0 );
            }
        }

        System.out.println ( "No" );

    }
}


from collections import Counter
for _ in range(int(input())):
    s=input();c=Counter(s)
    d=min(c.values())
    if d<1:print("NET")
    else:
        ans='DA' if d%2 else "NET"
        print(ans)


from collections import Counter
for _ in range(int(input())):
    s=input();c=Counter(s)
    d=min(c.values())
    ans="DA" if d%2 else "NET"
    print(ans)


for _ in range(int(input())):
    s=input();n=len(s)
    if n<2:print("NET")
    else:
        d=len(s)//2
        ans='DA' if d%2 else "NET"
        print(ans)


for _ in range(int(input())):
    st=input()
    zer=st.count("0")
    one=st.count("1")
    fin=min(zer,one)
    if fin%2==0:
        print("NET")
    else:
        print("DA")


t=int(input())
for i in range(t):
    s=input()
    l=len(s)
    i=0
    a=0
    b=0
    while(l>1):
        if(i%2==0):
            a=1
            b=0
        else:
            b=1
            a=0
        i+=1
        l-=2
    if(a==1):
        print("DA")
    else:
        print("NET")


t=int(input())
for i in range(t):
    s=input()
    l=len(s)
    if(l%2==0):
        if(l%4==0):
            print("NET")
        else:
            print("DA")
    else:
        if((l-1)%4==0):
            print("NET")
        else:
            print("DA")


from collections import Counter
t=int(input())
for i in range(t):
    s=input()
    c=(Counter(s))
    c=list(c.values())
    if('1' in s and '0' in s):
        a=min(c[0],c[1])
        if(a%2==0):
            print("NET")
        else:
            print("DA")
    else:
        print("NET")


t=int(input())
for i in range(t):
    s=input()
    l=len(s)
    if(l%2==0):
        if(l%4==0):
            print("NET")
        else:
            print("DA")
    else:
        if((l-1)%4==0):
            print("DA")
        else:
            print("NET")


for i in range(int(input())):
    a=input()
    t=len(a)
    s=0
    while(t!=0):
        a=a.replace('01','a')
        a=a.replace('10','a')
        print(a)
        if 'a' not in a:
            break
        else:
            t-=2*a.count('a')
            s+=a.count('a')
            a=a.replace('a','')
    if s%2==0:
        print('NET')
    else:
        print('DA')


for i in range(int(input())):print('DA' if set(input().replace('01','a'))=={'a'} else 'NET')


for i in range(int(input())):
    a=input()
    t=len(a)
    s=0
    while(t!=0):
        a=a.replace('01','a')
        a=a.replace('10','a')
        if 'a' not in a:
            break
        else:
            t-=2*a.count('a')
            s+=a.count('a')
            a=a.replace('a','')
    if s%2==0:
        print('NET')
    else:
        print('DA')


for _ in range(int(input()):
    n=input()
    on=n.count('1')
    z=n.count('0')
    y=min(on,z)
    if y%2!=0:
        print('DA')
    else:
        print('NET')


# -*- coding: utf-8 -*-
"""
Created on Mon Jul 13 10:30:34 2020

@author: Admin
"""
for _ in range(int(input())):
    s=str(input())
    c,new=0,s
    while ('1' not in new):
        if '10' in s:
            i=s.index('01')
            s=''.join(s.split(s[i]+s[i+1]))
            c+=1
        elif '01' in s:
            i=s.index('10')
            s=''.join(s.split(s[i]+s[i+1]))
            c+=1
        new=s
    if c%2 ==0 or c==2:
        print('NET')
    else:
        print('DA')


# -*- coding: utf-8 -*-
"""
Created on Mon Jul 13 10:30:34 2020

@author: Admin
"""
for _ in range(int(input())):
    s=str(input())
    c,new=0,s
    for _ in new:
        if '01' in s:
            i=s.index('01')
            new=''.join(s.split(s[i]+s[i+1]))
            c+=1
        elif '10' in s:
            i=s.index('01')
            new=''.join(s.split(s[i]+s[i+1]))
            c+=1
    if c%2 !=0 :
        print('DA')
    else:
        print('NET')


# -*- coding: utf-8 -*-
"""
Created on Mon Jul 13 10:30:34 2020

@author: Admin
"""
for _ in range(int(input())):
    s=str(input())
    c,new=0,s
    for _ in new:
        if '01' in s:
            i=s.index('01')
            s=''.join(s.split(s[i]+s[i+1]))
            c+=1
        elif '10' in s:
            i=s.index('01')
            s=''.join(s.split(s[i]+s[i+1]))
            c+=1
        new=s
    if c%2 !=0 :
        print('DA')
    else:
        print('NET')


for _ in range(int(input())):
    n=input()
    on=n.count('1')
    z=n.count('0')
    y=min(on,z)
    if y%2!=0:
        print('DA')
    else:
        print('NET')


# -*- coding: utf-8 -*-
"""
Created on Mon Jul 13 10:30:34 2020

@author: Admin
"""
for _ in range(int(input())):
    s=str(input())
    c=0
    for _ in s:
        if '01' in s:
            i=s.index('01')
            s=''.join(s.split(s[i]+s[i+1]))
            c+=1
        elif '10' in s:
            i=s.index('01')
            s=''.join(s.split(s[i]+s[i+1]))
            c+=1
    if c%2 !=0 :
        print('DA')
    else:
        print('NET')


# -*- coding: utf-8 -*-
"""
Created on Mon Jul 13 10:30:34 2020

@author: Admin
"""
for _ in range(int(input())):
    s=str(input())
    c,new=0,s
    for _ in new:
        if '01' in s:
            i=s.index('01')
            s=''.join(s.split(s[i]+s[i+1]))
            c+=1
        elif '10' in s:
            i=s.index('10')
            s=''.join(s.split(s[i]+s[i+1]))
            c+=1
        new=s
    if c%2 !=0 :
        print('DA')
    else:
        print('NET')


# -*- coding: utf-8 -*-
"""
Created on Mon Jul 13 10:30:34 2020

@author: Admin
"""
for _ in range(int(input())):
    s=str(input())
    c,new=0,s
    while ('1' not in new):
        if '10' in s:
            i=s.index('01')
            s=''.join(s.split(s[i]+s[i+1]))
            c+=1
        elif '01' in s:
            i=s.index('10')
            s=''.join(s.split(s[i]+s[i+1]))
            c+=1
        new=s
    if c%2 !=0 or c==1:
        print('DA')
    elif c%2 ==0 or c==2:
        print('NET')


test=int(input())
def solve():
    n=input()
    c0=0;c1=0
    for i in range(len(n)):
        if n[i]=='0':
            c0+=1
        if n[i]=='1':
            c1+=1
        print(min(c1,c0))
while test:
    solve()
    test-=1


test=int(input())
def solve():
    n=input()
    c0=0;c1=0
    for i in range(len(n)):
        if n[i]=='0':
            c0+=1
        if n[i]=='1':
            c1+=1
    if min(c1,c0)%2==0:
        print("NET")
    else:
        print("DA")
while test:
    solve()
    test-=1


test=int(input())
def solve():
    n=input()
    c0=0;c1=0
    for i in range(len(n)):
        if n[i]=='0':
            c0+=1
        if n[i]=='1':
            c1+=1
    print(min(c1,c0))
while test:
    solve()
    test-=1


test=int(input())
def solve():
    n=input()
    for i in range(len(n)):
        if n[i]=='0':
            c0+=1
        if n[i]=='1':
            c1+=1
        print(min(c1,c0))
while test:
    solve()
    test-=1


t=int(input())
for i in range(t):
    s=input()
    l=list(s)
    x=0
    while True:
        x+=1
        if s.count('10')==0 and s.count('01')==0:
            if x%2!=0:
                print('NET')
            else:
                print('DA')
            break
        p=s.replace('10','')
        q=s.replace('10','',s.count('10'))
        q=q.replace('01','')
        if (p.count('10')+p.count('01'))%2!=x%2:
            if s.count('10')!=0:
                s=p
            else:
                s=q
        else:
            if s.count('01')!=0:
                s=q
            else:
                s=p


t=int(input())
for i in range(t):
    s=input()
    l=list(s)
    x=0
    while True:
        x+=1
        if s.count('10')==0 and s.count('01')==0:
            if x%2!=0:
                print('NET')
            else:
                print('DA')
            break
        elif s.count('10')>=s.count('01'):
            s=s.replace('10','')
        else:
            s=s.replace('01','')


t=int(input())
for i in range(t):
    s=input()
    l=list(s)
    x=0
    while True:
        x+=1
        if s.count('10')==0 and s.count('01')==0:
            if x%2!=0:
                print('NET')
            else:
                print('DA')
            break
        elif s.count('10')!=0:
            s=s.replace('10','')
        else:
            s=s.replace('01','')


t=int(input())
for i in range(t):
    s=input()
    x=s.count('1')
    y=s.count('0')
    z=min(x,y)
    if z%2!=0:
        print('DA')
    else:
        print('NET')


t=int(input())
for i in range(t):
    s=input()
    l=list(s)
    x=0
    while True:
        x+=1
        if s.count('10')==0 and s.count('01')==0:
            if x%2!=0:
                print('NET')
            else:
                print('DA')
            break
        p=s.replace('10','')
        q=s.replace('01','')
        if (p.count('10')+p.count('01'))%2!=x%2:
            if s.count('10')!=0:
                s=p
            else:
                s=q
        else:
            if s.count('01')!=0:
                s=q
            else:
                s=p