Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was.

Its most important components are a button and a line of n similar gears. Each gear has n teeth containing all numbers from 0 to n - 1 in the counter-clockwise order. When you push a button, the first gear rotates clockwise, then the second gear rotates counter-clockwise, the the third gear rotates clockwise an so on.

Besides, each gear has exactly one active tooth. When a gear turns, a new active tooth is the one following after the current active tooth according to the direction of the rotation. For example, if n = 5, and the active tooth is the one containing number 0, then clockwise rotation makes the tooth with number 1 active, or the counter-clockwise rotating makes the tooth number 4 active.

Andrewid remembers that the real puzzle has the following property: you can push the button multiple times in such a way that in the end the numbers on the active teeth of the gears from first to last form sequence 0, 1, 2, ..., n - 1. Write a program that determines whether the given puzzle is real or fake.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 1000) — the number of gears.

The second line contains n digits a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ n - 1) — the sequence of active teeth: the active tooth of the i-th gear contains number a_{i}.


-----Output-----

In a single line print "Yes" (without the quotes), if the given Stolp's gears puzzle is real, and "No" (without the quotes) otherwise.


-----Examples-----
Input
3
1 0 0

Output
Yes

Input
5
4 2 1 4 3

Output
Yes

Input
4
0 2 3 1

Output
No



-----Note-----

In the first sample test when you push the button for the first time, the sequence of active teeth will be 2 2 1, when you push it for the second time, you get 0 1 2.

Source: codeforces | Difficulty: EASY
Tags: Implementation

Complete search


Solutions:
n = int(input())
arr = list(map(int, input().split()))
r = n - arr[0]
p = 1
c = -1
for i in range(n):
	if p == 1:
		t = (arr[i] + r) % n
	else:
		t = (n - (r - arr[i])) % n
	p = -p
	if t > c:
		c = t
	else:
		print('No')
		break
else:
	print('Yes')


completo = False

def lol(l):
	como_estas = len(l)
	for amigo in range(como_estas):
		if amigo % 2 == 0:
			l[amigo] = (l[amigo] + 1) % como_estas
		else:
			l[amigo] = (l[amigo] - 1) % como_estas
	return l
en = int(input())
numeros = input().split(' ')
integ = []
for numero in numeros:
	integ.append(int(numero))
cero = []
for numero in range(en):
	cero.append(numero)
for i in range(en + 1337):
	integ = lol(integ)
	if integ == cero and completo == False:
		print('Yes')
		completo = True
if completo == False:
	print('No')


from sys import stdout
n = int(input())
gears = list(map(int, input().split()))
targetGears = []
for i in range(0, n):
	targetGears.append(i)

def check():
	for i in range(0, n):
		if gears == targetGears:
			stdout.write('Yes')
			return
		for j in range(0, n):
			gears[j] += 1 if j % 2 == 0 else -1
			gears[j] %= n
	stdout.write('No')
check()


n = int(input())
arr = [int(x) for x in input().split()]
for _ in range(n + 7):
	for i in range(n):
		if i % 2 == 0:
			arr[i] += 1
			arr[i] %= n
		else:
			arr[i] -= 1
			if arr[i] == -1:
				arr[i] = n - 1
	okay = True
	for i in range(n):
		if i != arr[i]:
			okay = False
			break
	if okay:
		print('Yes')
		return
print('No')


n = int(input())
a = [int(x) for x in input().split()]
diff = (n - a[0]) % n
for i in range(1, n):
	if i % 2 == 0:
		if (a[i] + diff) % n != i:
			print('No')
			exit()
	elif (a[i] - diff) % n != i:
		print('No')
		exit()
print('Yes')


import unittest
import sys
import re

class Fake:

	def __init__(self, args):
		self.list = args
		self.n = len(self.list)

	def rotate(self):
		for i in range(self.n):
			if not i % 2:
				self.list[i] += 1
			else:
				self.list[i] -= 1
			self.list[i] %= self.n

	def calculate(self):
		result = 0
		for i in range(self.n):
			prev = -1
			match = 1
			for n in self.list:
				if n == prev + 1:
					pass
				else:
					match = 0
				prev = n
			if match:
				result = 1
				break
			self.rotate()
		return 'Yes' if result else 'No'

def get_inputs(test_inputs=None):
	it = iter(test_inputs.split('\n')) if test_inputs else None

	def uinput():
		if it:
			return next(it)
		else:
			return input()
	num = int(uinput())
	nums = [int(s) for s in uinput().split()]
	return nums

def calculate(test_inputs=None):
	return Fake(get_inputs(test_inputs)).calculate()

class unitTests(unittest.TestCase):

	def test_sample_tests(self):
		self.assertEqual(calculate('3\n1 0 0'), 'Yes')
		self.assertEqual(calculate('5\n4 2 1 4 3'), 'Yes')
		self.assertEqual(calculate('4\n0 2 3 1'), 'No')

	def test_get_inputs(self):
		self.assertEqual(get_inputs('3\n1 0 0'), [1, 0, 0])

	def test_Fake_class__basic_functions(self):
		d = Fake([1, 0, 0])
		self.assertEqual(d.list, [1, 0, 0])
		self.assertEqual(d.n, 3)
		d.rotate()
		self.assertEqual(d.list, [2, 2, 1])
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
print(calculate())


n = int(input())
a = [int(x) for x in input().split()]
t = a[0]
b = [(a[x] - (-1) ** (x % 2) * t + n) % n for x in range(len(a))]
c = [(a[x] + (-1) ** (x % 2) * (n - t) + n) % n for x in range(len(a))]
if b == list(range(n)) or c == list(range(n)):
	print('Yes')
else:
	print('No')


def main():
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(1, n + 1, 1):
		ok = 0
		v = []
		for j in range(n):
			v.append((a[j] - i + n) % n if j & 1 else (a[j] + i + n) % n)
		for k in range(n - 1):
			if v[k] != v[k + 1] - 1:
				ok = 1
		if ok == 0:
			print('YES')
			break
	else:
		print('NO')
main()


def main():
	n = int(input())
	l = list(map(int, input().split()))
	a = l[0]
	for (i, x) in enumerate(l):
		l[i] = ((x + a if i & 1 else x - a) - i) % n
	print(('Yes', 'No')[any(l)])
main()


from sys import stdin
inFile = stdin
tokens = []
tokens_next = 0

def next_str():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = inFile.readline().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())

def rotate(a):
	n = len(a)
	clock = 1
	for i in range(n):
		if clock:
			a[i] += 1
			a[i] %= n
		else:
			a[i] -= 1
			a[i] %= n
			a[i] += n
			a[i] %= n
		clock = 1 - clock
	return a

def check(a):
	b = list(range(len(a)))
	return all((a[i] == b[i] for i in range(len(a))))
n = nextInt()
a = [nextInt() for i in range(n)]
for i in range(n):
	a = rotate(a)
	if check(a):
		print('YES')
		exit()
print('NO')


n = int(input())
d = [1, -1]
print('YNeos'[len({(d[i % 2] * (i - x) + n) % n for (i, x) in enumerate(map(int, input().split()))}) > 1::2])


n = int(input())
a = list(map(int, input().split()))
print(('Yes', 'No')[any([(a[i] - (-1) ** (i & 1) * a[0]) % n != i for i in range(n)])])


def inp(s):
	j = 0
	a = []
	for i in range(len(s)):
		if s[i] == ' ':
			a.append(int(s[j:i]))
			j = i + 1
		if i == len(s) - 1:
			a.append(int(s[j:]))
	return a

def chk(a):
	f = 0
	for i in range(len(a)):
		if a[i] != i:
			f = 1
			break
	return f
n = int(input())
s = input()
a = inp(s)
x = a
for i in range(n):
	f = 0
	if chk(a) == 0:
		f = 1
		break
	for i in range(len(a)):
		if i % 2 == 0:
			a[i] = (a[i] - 1) % n
		else:
			a[i] = (a[i] + 1) % n
if f == 1:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
x = (0 - a[0]) % n
for i in range(1, n):
	if (a[i] + x * (-1) ** i) % n != i:
		print('No')
		exit(0)
print('Yes')


n = int(input())
z = input().split(' ')
y = [int(i) for i in z]
k = y[0]
x = [(y[i] - k * (-1) ** i) % n for i in range(n)]
print('Yes' if x == list(range(n)) else 'No')


n = int(input())
a = list(map(int, input().split()))
c = n - a[0]
f = True
for i in range(1, n):
	if i % 2 == 0:
		x = a[i] + c
		if x >= n:
			x -= n
	else:
		x = a[i] - c
		if x < 0:
			x += n
	if x != i:
		f = False
		break
if f:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
i = 0
y = False
while i < n and (not y):
	for j in range(n):
		if j % 2 == 0:
			a[j] += 1
			if a[j] == n:
				a[j] = 0
		else:
			a[j] -= 1
			if a[j] == -1:
				a[j] = n - 1
	yy = True
	for j in range(1, n):
		if a[j] != a[j - 1] + 1:
			yy = False
	y = yy
	i += 1
if y:
	print('Yes')
else:
	print('No')


N = int(input(''))
L = [int(i) for i in input('').split()]
K = [int(i) for i in L]
seq = [int(i) for i in range(N)]
while True:
	for i in range(0, N):
		if i % 2 == 0:
			K[i] = (K[i] + 1) % N
		else:
			K[i] = (K[i] - 1) % N
	if K == seq or K == L:
		break
if K == seq:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
for i in range(n + 1):
	for j in range(n):
		if j % 2 == 0:
			a[j] = (a[j] + 1) % n
		else:
			a[j] = (a[j] - 1) % n
	for j in range(n):
		if a[j] != j:
			break
	else:
		print('Yes')
		return
print('No')


n = int(input())
l = [int(i) for i in input().split()]
d = (n - l[0]) % n
for i in range(1, n):
	r = n
	if i & 1 == 0:
		if i >= l[i]:
			r = i - l[i]
		else:
			r = i - l[i] + n
	elif i <= l[i]:
		r = l[i] - i
	else:
		r = l[i] - i + n
	if r != d:
		print('No')
		d = -1
		break
if d >= 0:
	print('Yes')


n = int(input())
data = [int(x) for x in input().split()]
start = data[0]
moves = n - start
for i in range(n):
	if not i % 2:
		data[i] = (data[i] + moves) % n
	else:
		data[i] = data[i] - moves
		if data[i] < 0:
			data[i] = data[i] + n
	if data[i] != i:
		print('No')
		break
else:
	print('Yes')


R = input
n = int(R())
a = list(map(int, R().split())) + [n]
s = 'No'
for _ in range(n):
	y = 1
	for i in range(len(a) - 1):
		if a[i] + 1 != a[i + 1]:
			y = 0
		if i % 2 == 0:
			a[i] += 1
		else:
			a[i] -= 1
		a[i] = (a[i] + n) % n
	if y:
		s = 'Yes'
print(s)


__author__ = 'Administrator'
n = int(input())
str = input().split(' ')
d = n - int(str[0])
ans = True
for i in range(1, n):
	str[i] = int(str[i])
	if i % 2 == 1 and (n + str[i] - d) % n != i:
		ans = False
	if i % 2 == 0 and (d + str[i]) % n != i:
		ans = False
if ans:
	print('Yes')
else:
	print('No')


n = int(input())
mas = list(map(int, input().split(' ')))
for i in range(2 * n):
	for j in range(n):
		if j % 2 == 0:
			if mas[j] < n - 1:
				mas[j] += 1
			else:
				mas[j] = 0
		elif mas[j] == 0:
			mas[j] = n - 1
		else:
			mas[j] -= 1
	p = 1
	for j in range(n):
		if mas[j] != j:
			p = 0
			break
	if p:
		print('YES')
		break
else:
	print('NO')


def solve(n, seq):
	if seq[0] != 0:
		move = n - seq[0]
	else:
		move = 0
	index = 1
	while index < n:
		if index % 2 == 0:
			if (seq[index] + move) % n != index:
				return 'No'
		else:
			toZero = seq[index]
			if move > toZero:
				remain = move - toZero
				remain -= 1
				if n - 1 - remain != index:
					return 'No'
			elif seq[index] - move != index:
				return 'No'
		index += 1
	return 'Yes'
n = int(input())
seq = list(map(int, input().split()))
print(solve(n, seq))


n = int(input())
sample = list(range(n))
A = list(map(int, input().split()))
for i in range(n):
	if [(A[j] - i if j % 2 else A[j] + i) % n for j in range(n)] == sample:
		print('Yes')
		break
else:
	print('No')


(n, a) = (int(input()), list(map(int, input().split())))
dlt = [(n - a[0]) % n, (a[0] - n) % n]
for i in range(n):
	if (a[i] + dlt[i % 2]) % n != i:
		print('No')
		exit(0)
print('Yes')


n = input()
n = int(n)
s = input()
a = [int(i) for i in s.split()]
b = [int(i) for i in range(n)]
for i in range(n):
	if a == b:
		print('Yes')
		break
	for j in range(int((n + 1) / 2)):
		if a[2 * j] == n - 1:
			a[2 * j] = 0
		else:
			a[2 * j] = a[2 * j] + 1
	for j in range(int(n / 2)):
		if a[2 * j + 1] == 0:
			a[2 * j + 1] = n - 1
		else:
			a[2 * j + 1] = a[2 * j + 1] - 1
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
res = [x for x in range(n)]
j = 0
flag = True
while j < n:
	for i in range(n):
		if i % 2 != 0:
			if a[i] == 0:
				a[i] = n - 1
			else:
				a[i] -= 1
		elif a[i] == n - 1:
			a[i] = 0
		else:
			a[i] += 1
	if a == res:
		print('Yes')
		flag = True
		break
	else:
		flag = False
	j += 1
if not flag:
	print('No')


n = int(input())
string = input()
teeth = list(map(int, string.split()))
condition1 = False
for x in range(n):
	condition2 = True
	for y in range(n):
		if teeth[y] != y:
			condition2 = False
			break
	if condition2:
		condition1 = True
		break
	for y in range(n):
		if y % 2 == 0:
			teeth[y] += 1
			if teeth[y] == n:
				teeth[y] = 0
		else:
			teeth[y] -= 1
			if teeth[y] == -1:
				teeth[y] = n - 1
if condition1:
	print('Yes')
else:
	print('No')


N = int(input())
G = list(map(int, input().split()))
real = [i for i in range(N)]
d = [1, -1]
if G == real:
	print('Yes')
else:
	for i in range(N):
		for j in range(N):
			G[j] = real[(G[j] + d[j % 2]) % N]
		if G == real:
			print('Yes')
			break
	else:
		print('No')


n = int(input())
ar = []
a = list(map(int, input().split()))
for i in range(n):
	if i % 2 == 0:
		ar.append((n + i - a[i]) % n)
	else:
		ar.append((n - i + a[i]) % n)
ans = 'Yes'
for i in range(1, n):
	if ar[i] != ar[i - 1]:
		ans = 'No'
print(ans)


n = int(input())
arr = input().split(' ')
for i in range(n):
	arr[i] = int(arr[i])
rotate = (n - arr[0]) % n
for i in range(1, n):
	if i % 2 == 0:
		if (arr[i] + rotate) % n != i:
			print('No')
			quit()
	elif (arr[i] - rotate) % n != i:
		print('No')
		quit()
print('Yes')


__author__ = 'Andrey'

def switch(i):
	global n
	global active
	if i % 2 == 0:
		if active[i] == n - 1:
			active[i] = 0
		else:
			active[i] += 1
	elif active[i] == 0:
		active[i] = n - 1
	else:
		active[i] -= 1
n = int(input())
active = list(map(int, input().split()))
compare = [i for i in range(n)]
tried = 0
while tried < n:
	for i in range(n):
		switch(i)
	if active == compare:
		print('YES')
		break
	tried += 1
else:
	print('NO')


N = int(input())
A = list(map(int, input().split()))
cnt = N - A[0]
for i in range(N):
	if i % 2 == 0:
		A[i] += cnt
	else:
		A[i] -= cnt
	A[i] %= N
for i in range(N):
	if A[i] != i:
		print('No')
		exit()
print('Yes')


def turn(a, n):
	counter = 2
	for i in range(len(a)):
		if i % 2 == 0:
			a[i] = (a[i] + 1) % n
		else:
			a[i] = (a[i] - 1) % n
	return a
n = int(input())
a = list(map(int, input().split()))
array = [i for i in range(n)]
f = False
for i in range(n):
	if a == array:
		f = True
	if f:
		print('Yes')
		break
	a = turn(a, n)
if not f:
	print('No')


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	for j in range(n):
		if j & 1:
			if a[j] == 0:
				a[j] = n - 1
			else:
				a[j] -= 1
		elif a[j] == n - 1:
			a[j] = 0
		else:
			a[j] += 1
	if all((a[i + 1] - a[i] == 1 for i in range(len(a) - 1))):
		print('Yes')
		break
else:
	print('No')


n = int(input())
l = list(map(int, input().split()))
check = 0
for i in range(n):
	for i in range(n):
		if i % 2 == 0:
			l[i] = (l[i] + 1) % n
		else:
			l[i] = (l[i] - 1) % n
	ch = 1
	for i in range(n):
		if l[i] != i:
			ch = 0
			break
	if ch:
		check = 1
		break
if check:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
while a[0] != 0:
	for i in range(n):
		if i % 2 == 0:
			a[i] = (a[i] + 1) % n
		else:
			a[i] = (a[i] - 1) % n
b = True
for i in range(n):
	if a[i] != i:
		b = False
if b:
	print('Yes')
else:
	print('No')


n = int(input())
A = list(map(int, input().split()))
print('Yes' if all(((A[i] - A[0] * (-1) ** i) % n == i for i in range(n))) else 'No')


n = int(input())
a = [int(x) for x in input().split()]
if a[0] != 0:
	dif = n - a[0]
	for i in range(n):
		if i % 2:
			if a[i] >= dif:
				a[i] -= dif
			else:
				a[i] += n - dif
		else:
			a[i] = (a[i] + dif) % n
for i in range(n):
	if a[i] != i:
		print('No')
		break
else:
	print('Yes')


import time
n = int(input())
A = [int(i) for i in input().split()]
start = time.time()
if A[0] != 0:
	k = n - A[0]
else:
	k = 0
for j in range(n):
	x = divmod(j, 2)[1]
	if x == 0:
		A[j] += k
		if A[j] >= n:
			A[j] -= n
	else:
		A[j] -= k
		if A[j] < 0:
			A[j] += n
ans = 'YES'
for i in range(n):
	if A[i] != i:
		ans = 'NO'
		break
print(ans)
finish = time.time()


N = int(input())
A = list(map(int, input().split(' ')))

def rotate(A):
	return [(a + (-1) ** i) % N for (i, a) in enumerate(A)]

def ok(A):
	while True:
		A = rotate(A)
		if A[0] == 0:
			return A == list(range(N))
if ok(A):
	print('Yes')
else:
	print('No')


(n, t) = (int(input()), 0)
for (i, g) in enumerate(map(int, input().split())):
	if i == 0:
		t = (n - g) % n
	elif (g + t * (-1) ** i) % n != i:
		print('No')
		exit()
print('Yes')


n = int(input())
c = list(map(int, input().split()))
u = set()
r = True
while len(u) < n:
	u.add(c[0])
	for i in range(n):
		if i % 2 == 0:
			c[i] = (c[i] + 1) % n
		else:
			c[i] = (c[i] - 1) % n
	r = True
	for i in range(n):
		if c[i] != i:
			r = False
			break
	if r:
		break
if r:
	print('Yes')
else:
	print('No')


from collections import deque
n = int(input())
l = list(map(int, input().split()))
d = [deque() for i in range(n)]
t = -1
for i in l:
	t += 1
	for j in range(i, n):
		d[t].append(j)
	for j in range(0, i):
		d[t].append(j)
count = 0
while True:
	count += 1
	flag = 1
	for i in range(len(d)):
		if flag == 1:
			d[i].rotate(1)
		else:
			d[i].rotate(-1)
		flag *= -1
	i = -1
	flag = True
	for j in range(len(d)):
		i += 1
		if i != d[j][0]:
			flag = False
	if flag:
		print('Yes')
		break
	if count > n:
		flag = False
		break
if not flag:
	print('No')


n = int(input())
l = list(map(int, input().split()))
steps = -l[0]
l[0] = 0
for i in range(1, n):
	if i % 2 == 1:
		l[i] = (l[i] - steps) % n
	if i % 2 == 0:
		l[i] = l[i] + steps
		if l[i] < 0:
			l[i] = n + l[i]
if l == list(range(n)):
	print('YES')
else:
	print('NO')


n = int(input())
c = [i for i in range(n)]
a = list(map(int, input().split()))
for i in range(len(a)):
	for j in range(len(a)):
		if j % 2 == 0:
			a[j] += 1
			a[j] = a[j] % n
		elif a[j] == 0:
			a[j] = n - 1
		else:
			a[j] -= 1
	if a == c:
		print('Yes')
		exit()
print('No')


n = int(input())
puzzle = [int(x) for x in input().split()]
nums = puzzle
puzzle = tuple(puzzle)
real = []
for loop in range(n):
	real.append(loop)
while True:
	for loop in range(n):
		if loop % 2 == 0:
			if nums[loop] == n - 1:
				nums[loop] = 0
			else:
				nums[loop] += 1
		elif nums[loop] == 0:
			nums[loop] = n - 1
		else:
			nums[loop] -= 1
	if nums == real:
		print('Yes')
		break
	if list(puzzle) == nums:
		print('No')
		break


import sys
n = int(input())
a = list(map(int, input().split()))
for i in range(n + 1):
	for j in range(n):
		if j % 2:
			a[j] -= 1
		else:
			a[j] += 1
		a[j] %= n
	if a == list(range(n)):
		print('Yes')
		sys.exit(0)
print('No')


n = int(input())
a = list(map(int, input().split()))
e = n
s = 1
c1 = 0
while e != 0:
	s = 1
	for i in range(len(a)):
		if i % 2 == 0:
			a[i] = a[i] + 1
			if a[i] == n:
				a[i] = 0
		elif i % 2 != 0:
			a[i] = a[i] - 1
			if a[i] == -1:
				a[i] = n - 1
		if i > 0:
			if a[i] == a[i - 1] + 1:
				s = s + 1
	if s == n:
		c1 = -1
		print('Yes')
		break
	e = e - 1
if c1 != -1:
	print('No')


n = int(input())
l = list(map(int, input().split()))
t = n - l[0]
for i in range(len(l)):
	l[i] = l[i] + t
	t = -t
for i in range(len(l)):
	if l[i] < 0:
		l[i] = l[i] + n
for i in range(len(l)):
	l[i] = l[i] % n
l
flag = True
for i in range(len(l)):
	if l[i] != i:
		flag = False
		print('No')
		break
if flag:
	print('Yes')


n = int(input())
a = [int(i) for i in input().split()]
bo = 0
for i in range(n):
	bo = 0
	count = 0
	for j in range(n - 1):
		if a[j + 1] - a[j] == 1:
			count += 1
	if count == n - 1:
		bo = 1
		break
	for k in range(n):
		if k % 2 == 0:
			if a[k] == n - 1:
				a[k] = 0
			else:
				a[k] += 1
		elif a[k] == 0:
			a[k] = n - 1
		else:
			a[k] -= 1
if bo:
	print('Yes')
else:
	print('No')


n = int(input())
s = []
for i in range(n):
	s.append(i)
l = input().split()
for i in range(n):
	l[i] = int(l[i])
j = 0
while s != l and j < n:
	for i in range(n):
		if i % 2 == 0:
			if l[i] == n - 1:
				l[i] = 0
			else:
				l[i] += 1
		elif l[i] == 0:
			l[i] = n - 1
		else:
			l[i] -= 1
	j += 1
if s == l:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
	a[i] = [a[i] + n - a[0], a[i] - n + a[0]][i % 2] % n
print('YNeos'[a[1:] != list(range(1, n))::2])


def testYes(l):
	for i in range(len(l) - 1):
		if l[i + 1] - l[i] != 1:
			return False
	return True
num = int(input())
l = list(map(int, input().split()))
copylist = l.copy()
res = False
while True:
	flag = 0
	if testYes(l) == True:
		res = True
		break
	for i in range(len(l)):
		if flag == 0:
			if l[i] < num - 1:
				l[i] = l[i] + 1
			elif l[i] == num - 1:
				l[i] = 0
			flag = 1
		else:
			if l[i] > 0:
				l[i] = l[i] - 1
			elif l[i] == 0:
				l[i] = num - 1
			flag = 0
	if l == copylist:
		res = False
		break
if res == True:
	print('Yes')
else:
	print('No')


n = int(input())
alist = list(map(lambda t: int(t), input().split()))
dist = n - alist[0]
if alist[0] == 0:
	dist = 0

def value_distance(idx, a, dist):
	if idx % 2 == 0:
		return (a + dist) % n
	return (a - dist) % n
for (idx, x) in enumerate(alist):
	if value_distance(idx, x, dist) != idx:
		print('No')
		exit()
print('Yes')


import sys
sys.setrecursionlimit(1000000000)
n = int(input())
s = input().split()
t = []
for i in range(n):
	t += [int(s[i])]
x = 0
if t[0] != 0:
	x = n - t[0]
bb = True
for i in range(n):
	if i % 2 == 0 and (t[i] + x) % n != i:
		bb = False
	if i % 2 == 1 and (t[i] - x) % n != i:
		bb = False
if bb:
	print('Yes')
else:
	print('No')


import functools as ft
n = int(input())
a = list(map(int, input().split()))
b = [i for i in range(n)]
for i in range(1, n + 1):
	a = [(a[j] + 1) % n if not j % 2 else (a[j] - 1) % n for j in range(n)]
	cnt = ft.reduce(lambda x, y: x + y, [a[j] == b[j] for j in range(n)])
	if cnt == n:
		print('YES')
		break
else:
	print('NO')


n = int(input())
a = [int(x) for x in input().split()]
c = a[0]
res = 'yes'
for i in range(n):
	if i % 2 == 0:
		if (a[i] - c + n) % n != i:
			res = 'no'
	elif (a[i] + c) % n != i:
		res = 'no'
print(res)


def main():
	l = int(input())
	s = [int(i) for i in input().split(' ')]
	r = list(range(l))
	k = list(map(lambda v: -1 if v % 2 else 1, r))
	for i in range(l):
		s = list(map(lambda x, y: (x + y) % l, s, k))
		if s == r:
			print('Yes')
			return 0
	print('No')
main()


def main():
	n = int(input())
	a = [int(t) for t in input().split()]
	shift = n - a[0]
	turn = 1
	out = 'Yes'
	for i in range(len(a)):
		a[i] = (a[i] + turn * shift) % n
		turn *= -1
		if a[i] != i:
			out = 'No'
			break
	print(out)

def __starting_point():
	main()
__starting_point()


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
while arr[0] != 0:
	for i in range(n):
		if i % 2 == 0:
			if arr[i] != n - 1:
				arr[i] += 1
			else:
				arr[i] = 0
		elif arr[i] != 0:
			arr[i] -= 1
		else:
			arr[i] = n - 1
check = 0
for i in range(1, n):
	if arr[i] - arr[i - 1] != 1:
		check = 1
		break
if check == 0:
	sys.stdout.write('Yes')
else:
	sys.stdout.write('No')


alph = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
a = list(map(int, input().split()))
p = (n - a[0]) % n
for j in range(n):
	if j % 2 == 0:
		if a[j] > j:
			r = n + j - a[j]
		elif a[j] == j:
			r = 0
		else:
			r = j - a[j]
	elif a[j] > j:
		r = a[j] - j
	elif a[j] == j:
		r = 0
	else:
		r = a[j] + n - j
	if r != p:
		print('No')
		break
else:
	print('Yes')


def changeGear(x, i, n):
	if i & 1 == 0:
		if x != n - 1:
			return x + 1
		else:
			return 0
	elif x == 0:
		return n - 1
	else:
		return x - 1
n = int(input())
a = list(map(int, input().split()))
b = []
c = []
for i in range(n):
	b.append(i)
	c.append(a[i])
if a == b:
	print('Yes')
	return
else:
	for i in range(n):
		a[i] = changeGear(a[i], i, n)
while a != b and a != c:
	for i in range(n):
		a[i] = changeGear(a[i], i, n)
if a == b:
	print('Yes')
else:
	print('No')


n = int(input())
g = list(map(int, input().split()))
left = g[0]
right = n - g[0]
i = 0
while i < n and (g[i] + [-left, +left][i % 2]) % n == i:
	i += 1
if i == n:
	print('Yes')
	exit()
i = 0
while i < n and (g[i] + [right, -right][i % 2]) % n == i:
	i += 1
if i == n:
	print('Yes')
	exit()
print('No')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy
from itertools import chain, dropwhile, permutations, combinations
from collections import defaultdict, deque

def VI():
	return list(map(int, input().split()))

def I():
	return int(input())

def LIST(n, m=None):
	return [0] * n if m is None else [[0] * m for i in range(n)]

def ELIST(n):
	return [[] for i in range(n)]

def MI(n=None, m=None):
	if n is None:
		(n, m) = VI()
	arr = LIST(n)
	for i in range(n):
		arr[i] = VI()
	return arr

def MS(n=None, m=None):
	if n is None:
		(n, m) = VI()
	arr = LIST(n)
	for i in range(n):
		arr[i] = input()
	return arr

def MIT(n=None, m=None):
	if n is None:
		(n, m) = VI()
	a = MI(n, m)
	arr = LIST(m, n)
	for (i, l) in enumerate(a):
		for (j, x) in enumerate(l):
			arr[j][i] = x
	return arr

def run(n, a):
	for i in range(n + 1):
		if a[0] == 0:
			if sum([i == a[i] for i in range(n)]) == n:
				print('Yes')
			else:
				print('No')
			return
		for j in range(n):
			if j % 2 == 0:
				a[j] = (a[j] + 1) % n
			else:
				a[j] = (a[j] - 1) % n

def main(info=0):
	n = I()
	a = VI()
	run(n, a)

def __starting_point():
	main()
__starting_point()


import sys
import collections
sys.setrecursionlimit(30000)

def main():
	n = int(input())
	a = [int(it) for it in input().split()]
	for k in range(n):
		for i in range(n):
			if i % 2 == 0:
				a[i] += 1
			else:
				a[i] -= 1
			a[i] = (a[i] % n + n) % n
		ok = 0
		for j in range(n):
			if j == a[j]:
				ok += 1
		if ok == n:
			print('Yes')
			return 0
	print('No')
main()


__author__ = 'myduomilia'
n = int(input())
arr = list(map(int, input().split()))
ans = 'Yes'
val = 0
for i in range(len(arr)):
	if not i:
		while arr[i] != 0:
			val += 1
			arr[i] += 1
			if arr[i] == n:
				arr[i] = 0
	elif i % 2:
		j = val
		while j > 0:
			arr[i] -= 1
			j -= 1
			if arr[i] == -1:
				arr[i] = n - 1
		if arr[i] != i:
			ans = 'No'
			break
	else:
		j = val
		while j > 0:
			arr[i] += 1
			j -= 1
			if arr[i] == n:
				arr[i] = 0
		if arr[i] != i:
			ans = 'No'
			break
print(ans)


n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	for j in range(n + 1):
		if j == n:
			print('Yes')
			exit(0)
		if j & 1 == 0:
			if (l[j] + i) % n != j:
				break
		elif (l[j] + n - i) % n != j:
			break
print('No')


n = int(input())
z = [int(x) for x in input().split()]
w = []
for i in range(n):
	if i % 2 == 0:
		if z[i] <= i:
			w.append(i - z[i])
		else:
			w.append(n - z[i] + i)
	elif i <= z[i]:
		w.append(z[i] - i)
	else:
		w.append(z[i] + n - i)
for i in range(n - 1):
	if w[i] != w[i + 1]:
		print('No')
		return
print('Yes')


n = int(input())
a = list(map(int, input().split()))
if a[0] == 0:
	k = 0
else:
	k = n - a[0]
v = k
i = 1
while i < n and v == k:
	if i % 2 == 1:
		v = a[i] - i
	else:
		v = i - a[i]
	if v < 0:
		v = n + v
	i += 1
if i == n and v == k:
	print('Yes')
else:
	print('No')


n = int(input())
line = list(map(int, input().split()))
flag = True
for i in range(n):
	if (line[i] + (-line[0], line[0])[i % 2]) % n != i:
		flag = False
		break
print('Yes') if flag else print('No')


import sys
n = int(input())
teeth = list(map(int, input().split()))
delta = n - teeth[0]
for i in range(1, n):
	if i % 2 == 0:
		x = (teeth[i] + delta) % n
	else:
		x = (teeth[i] + n - delta) % n
	if x != i:
		print('No')
		sys.exit()
print('Yes')


import string
n = int(input())
k = input().split()
k = [int(x) for x in k]
f = 1
i = 0
h = 1
plus = 1
while i < n + 5 and f:
	i += 1
	if k[0] == 0:
		while h < n:
			if k[h] - k[h - 1] == 1:
				h += 1
			else:
				h = n + 1
		if h == n:
			f = 0
			i = n * 10
		h = 1
	for j in range(n):
		if j % 2:
			plus = 1
		else:
			plus = -1
		if k[j] == 0 and j % 2 == 0:
			k[j] = n - 1
		elif k[j] == n - 1 and j % 2 != 0:
			k[j] = 0
		else:
			k[j] += plus
if f == 0:
	print('Yes')
else:
	print('No')


t = int(input())
n = list(map(int, input().split()))
m = []
for i in range(t):
	m.append(i)
flag = 0
for j in range(t):
	for i in range(t):
		if i % 2 == 0:
			if n[i] == t - 1:
				n[i] = 0
			else:
				n[i] = n[i] + 1
		elif n[i] == 0:
			n[i] = t - 1
		else:
			n[i] = n[i] - 1
	if m == n:
		flag = 1
		print('YES')
		break
if flag == 0:
	print('NO')


from sys import stdin
n = int(stdin.readline())
an = list(map(int, stdin.readline().split()))
for i in range(0, n):
	c = True
	for j in range(0, n):
		if j % 2 == 0:
			if an[j] + 1 > n - 1:
				an[j] = 0
			else:
				an[j] += 1
		elif an[j] - 1 < 0:
			an[j] = n - 1
		else:
			an[j] -= 1
		if j > 0:
			if an[j] - an[j - 1] != 1:
				c = False
	if c == True:
		print('Yes')
		exit()
print('No')


n = int(input())
a = list(map(int, input().split()))
b = n - a[0]
ok = 1
for i in range(n):
	if (a[i] + b) % n != i and i % 2 == 0 or ((a[i] - b + n) % n != i and i % 2 == 1):
		ok = 0
if ok:
	print('Yes')
else:
	print('No')


n = int(input())
l_p = list(map(int, input().split()))
t = -l_p[0] % n
for i in range(n):
	if (l_p[i] + (-1 if i % 2 == 1 else 1) * t) % n != i:
		print('NO')
		quit()
print('YES')


n = int(input())
arr = [int(x) for x in input().split()]
flag = 1
t = n - arr[0]
if arr[0] == 0:
	t = 0
for i in range(n):
	cur = arr[i]
	if i % 2 == 0:
		cur = (cur + t) % n
	else:
		cur = (cur - t + n) % n
	if cur != i:
		flag = 0
if flag:
	print('Yes')
else:
	print('No')


from math import *
import random

def isSorted(list):
	for i in range(1, len(list)):
		if list[i] < list[i - 1]:
			return False
	return True

def stringToList(string):
	return [int(i) for i in string.split(' ')]

def isTrue(list):
	n = len(list)
	add = 0
	if list[0] == 0:
		pass
	else:
		add = n - list[0]
	for i in range(n):
		list[i] += add
		if list[i] >= n:
			list[i] -= n
		elif list[i] < 0:
			list[i] += n
		if i >= 1 and list[i] <= list[i - 1]:
			return False
		add = -add
	return True
_ = input()
inp = input()
list = stringToList(inp)
if isTrue(list):
	print('Yes')
else:
	print('No')


import sys
n = int(input())
a = [int(x) for x in input().split()]
for i in range(1000):
	turn = n - a[0]
	ok = True
	for i in range(len(a)):
		a[i] = (a[i] + (turn if i % 2 == 0 else -turn)) % n
		if a[i] != i:
			ok = False
	if ok:
		print('Yes')
		sys.exit(0)
print('No')


N = int(input())
X = list(map(int, input().split()))
Dif = N - X[0]
for i in range(N):
	if i % 2 == 0:
		X[i] = (X[i] + Dif) % N
	else:
		X[i] = X[i] - Dif if X[i] - Dif >= 0 else N - Dif + X[i]
for i in range(1, N):
	if X[i] - X[i - 1] != 1:
		print('No')
		exit()
print('Yes')


n = int(input())
z = [int(x) for x in input().split()]
a = n - z[0]
for i in range(1, n):
	b = z[i]
	v = i
	if b <= v:
		w = v - b
	else:
		w = n - b + v
	if w != n - a:
		print('No')
		exit(0)
	if w != 0:
		a = n - a
print('Yes')


n = int(input())
a = [int(i) for i in input().split(' ') if i.isdigit()]
flag = True
if n == 1:
	flag = False
if flag:
	for i in range(2, n, 2):
		if (a[i] - a[i - 2]) % n != 2:
			flag = False
			break
if flag:
	for i in range(3, n, 2):
		if (a[i] - a[i - 2]) % n != 2:
			flag = False
			break
if flag:
	off = (0 - a[0]) % n
	if (a[1] - off) % n != 1:
		flag = False
if n == 1:
	flag = True
if flag:
	print('Yes')
else:
	print('No')


a = int(input())
b = list(map(int, input().split()))
spins = a - b[0]
for i in range(0, a, 2):
	b[i] += spins
	b[i] %= a
for i in range(1, a, 2):
	b[i] -= spins
	b[i] %= a
if b == list(range(a)):
	print('Yes')
else:
	print('No')


n = int(input())
v = list(map(int, input().split()))
for i in range(n):
	prev = v[0]
	tf = True
	if prev == 0:
		for j in range(1, n):
			cur = v[j]
			if prev + 1 != cur:
				tf = False
				break
			prev = cur
	else:
		tf = False
	if tf == True:
		print('Yes')
		exit(0)
	for j in range(n):
		if j % 2 == 0:
			v[j] = (v[j] - 1) % n
		else:
			v[j] = (v[j] + 1) % n
print('No')


import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
delta = n - a[0]
for i in range(1, n):
	if i % 2 == 1:
		if (a[i] - delta) % n != i:
			print('No')
			break
	elif (a[i] + delta) % n != i:
		print('No')
		break
else:
	print('Yes')


n = int(input())
l = list(map(int, input().split()))
l1 = [i for i in range(n)]
while l[0] != 0:
	l[0] = l[0] + 1
	if l[0] == n:
		l[0] = 0
	for i in range(1, n):
		if (i + 1) % 2 == 0:
			if l[i] == 0:
				l[i] = n - 1
			else:
				l[i] = l[i] - 1
		elif l[i] == n - 1:
			l[i] = 0
		else:
			l[i] = l[i] + 1
if l == l1:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
k = n - a[0] if a[0] != 0 else 0
for i in range(0, n):
	if i % 2 == 0:
		a[i] = (a[i] + k) % n
	else:
		a[i] = (n + a[i] - k) % n
	if a[i] != i:
		print('No')
		break
else:
	print('Yes')


n = int(input())
a = list(map(int, input().split()))
d = a[0] - n
for i in range(1, n):
	if (a[i] + n + d) % n != i:
		print('NO')
		break
	d = -d
else:
	print('YES')


n = int(input())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
while a[0] != 0:
	for i in range(n):
		if i % 2 == 0:
			a[i] = (a[i] + 1) % n
		else:
			a[i] = (a[i] + (n - 1)) % n
good = True
for i in range(n):
	if a[i] != i:
		good = False
		print('No')
		break
if good:
	print('Yes')


from sys import stdin

def real_puzzle(n, active_teeth):
	while active_teeth[0] != 0:
		for i in range(n):
			if i % 2 == 0:
				active_teeth[i] = (active_teeth[i] + 1) % n
			else:
				active_teeth[i] = active_teeth[i] - 1 if active_teeth[i] != 0 else n - 1
	for i in range(n):
		if active_teeth[i] != i:
			return 'No'
	return 'Yes'
n = int(stdin.readline())
active_teeth = [int(c) for c in stdin.readline().split(' ')]
print(real_puzzle(n, active_teeth))


n = int(input())
gears = list(map(int, input().split()))
even = 1
odd = -1
if int(gears[0] / 2) < int(n / 2):
	even = -1
	odd = 1
while gears[0] != 0:
	for i in range(n):
		if i % 2 == 0:
			gears[i] = (gears[i] + even) % n
		else:
			gears[i] = (gears[i] + odd) % n
good = 'YES'
for i in range(n):
	if gears[i] != i:
		good = 'NO'
		break
print(good)


n = int(input())
a = list(map(int, input().split()))
for _ in range(n):
	for i in range(n - 1):
		if a[i] >= a[i + 1]:
			break
	else:
		print('Yes')
		exit()
	for i in range(n):
		if i % 2 == 0:
			a[i] = (a[i] + 1) % n
		else:
			a[i] = (a[i] - 1) % n
print('No')


n = int(input())
a = list(map(int, input().split()))
z = [i for i in range(n)]
t = a[0] - 0
for (i, v) in enumerate(a):
	v += t if i % 2 else -t
	if v < 0:
		v += n
	elif v >= n:
		v -= n
	a[i] = v
print('Yes' if a == z else 'No')


def main():
	n = int(input())
	a = [int(i) for i in input().split()]
	d = 0 if a[0] == 0 else n - a[0]
	for i in range(n):
		if i % 2 == 0:
			a[i] = (a[i] + d) % n
		else:
			a[i] = (a[i] - d + n) % n
	if a == list(range(n)):
		print('Yes')
	else:
		print('No')
main()


n = int(input())
arr = list(map(int, input().split())) + [n]
res = 'No'
for _ in range(n):
	y = True
	for i in range(n):
		if arr[i] + 1 != arr[i + 1]:
			y = False
		if i % 2 == 0:
			arr[i] += 1
		else:
			arr[i] -= 1
		arr[i] = (arr[i] + n) % n
	if y:
		res = 'Yes'
print(res)


n = int(input())
nums = list(map(int, input().split()))
diff = (0 - nums[0]) % n
m = -1
ok = True
for i in range(1, n):
	if (nums[i] + m * diff) % n != i:
		ok = False
	m *= -1
if ok:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split(' ')))
for i in range(n):
	prev = -1
	ok = True
	for j in range(len(a)):
		if j % 2 == 0:
			a[j] += 1
			if a[j] == n:
				a[j] = 0
		else:
			a[j] -= 1
			if a[j] < 0:
				a[j] = n - 1
		if a[j] - prev != 1:
			ok = False
		else:
			prev += 1
	if ok:
		print('YES')
		break
else:
	print('NO')


n = input()
li = input()
n = int(n)
li = li.split()
valid = 'Yes'
for i in range(0, n - 1):
	if (int(li[i]) + int(li[i + 1]) - 2 * i - 1) % n:
		valid = 'No'
		break
print(valid)


def rotate(a, n):
	clock = True
	for i in range(n):
		if clock:
			if a[i] == n - 1:
				a[i] = 0
			else:
				a[i] += 1
		elif a[i] == 0:
			a[i] = n - 1
		else:
			a[i] -= 1
		clock = not clock
	return a

def check(a):
	for i in range(len(a)):
		if a[i] != i:
			return False
	return True
n = int(input())
a = list(map(int, input().split()))
while a[0] != 0:
	a = rotate(a, n)
yes = check(a)
if yes:
	print('YES')
else:
	print('NO')


import sys
n = int(input())
l = list(map(int, input().split()))
lenn = len(l) - 1
temp = 0
if n == 1:
	print('Yes')
else:
	for k in range(n):
		temp = 0
		for i in range(len(l)):
			if i % 2 != 0:
				l[i] = l[i] - 1
				if l[i] < 0:
					l[i] = n - 1
			else:
				l[i] = l[i] + 1
				if l[i] == n:
					l[i] = 0
		for j in range(1, n):
			if l[j - 1] < l[j]:
				temp += 1
			else:
				break
		if temp == n - 1:
			print('Yes')
			break
		if k == n - 1:
			print('No')


def check(gears):
	for i in range(0, len(gears)):
		if gears[i] != i:
			return False
	return True
n = int(input())
gears = [int(i) for i in input().split()]
saved = set()
while True:
	current = str(gears)
	if current in saved:
		break
	saved.add(current)
	for i in range(0, n):
		if i % 2 == 0:
			gears[i] = (gears[i] + 1) % n
		else:
			gears[i] = (gears[i] - 1) % n
	if check(gears):
		break
if check(gears):
	print('Yes')
else:
	print('No')


n = int(input())
x = [int(x) for x in input().split()]
ns = n - x[0]
if ns > n - 1:
	ns -= n
for i in range(n):
	if i % 2 == 0:
		ans = n - x[i] + i
		if ans > n - 1:
			ans -= n
	else:
		ans = x[i] - i
		if ans < 0:
			ans += n
	if ns != ans:
		print('NO')
		exit()
print('YES')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect, insort
from time import perf_counter
from fractions import Fraction
import copy
from copy import deepcopy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
n = L()[0]
A = L()
B = [i for i in range(n)]
s = set()
ans = 'No'
while tuple(A) not in s:
	s.add(tuple(A))
	z = 1
	for i in range(n):
		A[i] = (A[i] + z) % n
		z *= -1
	if A == B:
		ans = 'Yes'
print(ans)
endtime = time.time()


n = int(input())
a = list(map(int, input().split()))
ok = 'No'
for j in range(n):
	for i in range(n):
		if i & 1 == 1:
			a[i] = (a[i] - 1) % n if a[i] != 0 else n - 1
		else:
			a[i] = (a[i] + 1) % n
	if a == sorted(a) and len(a) == len(set(a)):
		ok = 'Yes'
print(ok)


n = int(input())
arr = list(map(int, input().split()))
if arr[0] > 0:
	steps = n - arr[0]
else:
	steps = arr[0]
arr[0] = 0
for i in range(1, n):
	if (i + 1) % 2 == 0:
		num = arr[i] - steps
		arr[i] = num % n
	else:
		num = arr[i] + steps
		if num < n:
			arr[i] = num
		else:
			arr[i] = num % n
if arr == list(range(n)):
	print('Yes')
else:
	print('No')


from itertools import cycle
n = int(input())
l = list(map(int, input().split(' ')))
times_to_rotate = n - l[0]
for (count, (i, mul)) in enumerate(zip(l, cycle([1, -1]))):
	j = (i + times_to_rotate * mul) % n
	if j != count:
		print('No')
		break
else:
	print('Yes')


def check_order(_list: list) -> bool:
	for i in range(len(_list)):
		if _list[i] != i:
			return False
	return True

def check_repe(current_list: list, lib_list: [list]) -> bool:
	if current_list in lib_list:
		return True
	return False

def _up_push(x: int, maxi: int) -> int:
	if x + 1 == maxi:
		return 0
	return x + 1

def _down_push(x: int, maxi: int) -> int:
	if x == 0:
		return maxi - 1
	return x - 1

def move(_list: list) -> list:
	temp_list = []
	for i in range(len(_list)):
		if i % 2 == 0:
			temp_list.append(_up_push(_list[i], len(_list)))
		else:
			temp_list.append(_down_push(_list[i], len(_list)))
	return temp_list
number = int(input())
gear_list = list(map(int, input().split()))
lib = []
lib.append(gear_list)
if gear_list == [0] or check_order(gear_list):
	print('Yes')
else:
	while 1:
		gear_list = move(gear_list)
		if check_repe(gear_list, lib):
			status = 'repetition'
			break
		lib.append(gear_list)
		if check_order(gear_list):
			print('Yes')
			break
try:
	if status == 'repetition':
		print('No')
except NameError:
	pass


n = int(input())
a = [int(x) for x in map(int, input().split())]
c = 0
while a[0] != 0:
	a[0] = a[0] + 1
	a[0] = a[0] % n
	c = c + 1
for i in range(1, n):
	x = c
	while i % 2 and x > 0:
		if a[i] == 0:
			a[i] = n
		a[i] = a[i] - 1
		x = x - 1
	if i % 2 == 0:
		a[i] = a[i] + c
	if a[i] >= n:
		a[i] = a[i] % n
	elif a[i] < 0:
		a[i] = a[i] + c
for i in range(n):
	if a[i] != i:
		print('No')
		exit(0)
print('Yes')


(n, active_teeth) = (int(input()), list(map(int, input().split())))
move = n - active_teeth[0]
for i in range(n):
	if i % 2 == 0:
		if active_teeth[i] + move < n:
			active_teeth[i] = active_teeth[i] + move
		else:
			active_teeth[i] = active_teeth[i] + move - n
	elif active_teeth[i] - move > 0:
		active_teeth[i] = active_teeth[i] - move
	else:
		active_teeth[i] = n + (active_teeth[i] - move)
if active_teeth == list(range(n)):
	print('Yes')
else:
	print('No')


n = int(input())
gears = list(map(int, input().split()))
blah = sorted([i for i in range(n)])
good = False
for push in range(n):
	for i in range(len(gears)):
		if i % 2 == 0:
			gears[i] += 1
			if gears[i] == n:
				gears[i] = 0
		else:
			gears[i] -= 1
			if gears[i] == -1:
				gears[i] = n - 1
	if gears == blah:
		print('Yes')
		good = True
		break
if not good:
	print('No')


n = int(input())
g = list(map(int, input().split()))
if n == 1:
	print('Yes')
else:
	gImp = [g[2 * x] for x in range(int((n + 1) / 2))]
	gPar = [g[2 * y + 1] for y in range(int(n / 2))]
	ok = 1
	for i in range(len(gImp) - 1):
		if (gImp[i] + 2) % n != gImp[i + 1]:
			ok = 0
	for i in range(len(gPar) - 1):
		if (gPar[i] + 2) % n != gPar[i + 1]:
			ok = 0
	if (gPar[0] + gImp[0]) % n != 1:
		ok = 0
	if ok == 0:
		print('No')
	else:
		print('Yes')


n = int(input())
a = list(map(int, input().split()))
cnt = 0
if a[0] > 0:
	cnt = n - a[0]
flag = True
for i in range(1, n, 1):
	if i % 2 == 0:
		if a[i] > i:
			if n - a[i] + i != cnt:
				flag = False
				break
		elif a[i] < i:
			if i - a[i] != cnt:
				flag = False
				break
		elif a[i] == i and cnt != 0:
			flag = False
			break
	elif a[i] < i:
		if a[i] + n - i != cnt:
			flag = False
			break
	elif a[i] > i:
		if a[i] - i != cnt:
			flag = False
			break
	elif a[i] == i and cnt != 0:
		flag = False
		break
if flag == False:
	print('NO')
else:
	print('YES')


n = int(input())
a = [int(x) for x in input().split()]
good = list(range(n))
for i in range(n):
	if a == good:
		print('Yes')
		exit(0)
	for i in range(n):
		if i % 2 == 0:
			a[i] = (a[i] + 1) % n
		else:
			a[i] = (a[i] - 1) % n
print('No')


n = int(input())
l = list(map(int, input().split()))
s = (n - l[0]) * (l[0] != 0)
for i in range(1, n):
	if i % 2 == 0:
		if l[i] <= i:
			res = i - l[i]
		else:
			res = n - 1 - l[i] + i + 1
	elif l[i] >= i:
		res = l[i] - i
	else:
		res = l[i] + (n - 1 - i) + 1
	if res != s:
		print('No')
		exit(0)
print('Yes')


(n, a, move) = (int(input()), list(map(int, input().split())), [])
for i in range(n):
	if i & 1:
		move.append((a[i] + 1 + (n - 1 - i)) % n)
	else:
		move.append((n - a[i] + i) % n)
print('Yes' if len(set(move)) == 1 else 'NO')


N = int(input())
G = [int(x) for x in input().split()]
trueG = list(range(N))
for i in range(N):
	for j in range(N):
		G[j] = (G[j] + (-1 if j % 2 else 1)) % N
	if G == trueG:
		print('Yes')
		break
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	fl = True
	for j in range(n):
		if a[j] != j:
			fl = False
	if fl:
		print('YES')
		exit()
	for j in range(n):
		if j & 1:
			a[j] = (a[j] + n - 1) % n
		else:
			a[j] = (a[j] + 1) % n
print('NO')


n = int(input())
f = list(map(int, input().split()))
t = [i for i in range(n)]
g = 0
h = n // 1
while h:
	for j in range(n):
		if j % 2 == 0:
			f[j] = (f[j] + 1) % n
		elif f[j] == 0:
			f[j] = n - 1
		else:
			f[j] -= 1
	if t == f:
		print('Yes')
		g += 1
		break
	h -= 1
if g == 0:
	print('No')


n = int(input())
m = list(map(int, input().split()))
check = [i for i in range(n)]
rot = [(-1) ** i for i in range(n)]
q = 0
g = True
while q != n:
	for i in range(n):
		m[i] += rot[i]
		if m[i] < 0:
			m[i] = n - 1
		elif m[i] == n:
			m[i] = 0
	if m == check:
		print('Yes')
		g = False
		break
	q += 1
if g:
	print('No')


__author__ = 'y'
n = int(input())
a = list(map(int, input().split()))
sig = 1
for i in range(n):
	a[i] = sig * (i - a[i]) % n
	sig = -sig
fst = a[0]
ret = 'Yes'
for i in range(1, n):
	if a[i] != fst:
		ret = 'No'
		break
print(ret)


import sys

def solve():
	(n,) = rv()
	(a,) = rl(1)
	press = n - a[0]
	for i in range(n):
		change = press if i % 2 == 0 else -press
		a[i] = (change + n + a[i]) % n
	for i in range(n):
		if a[i] != i:
			print('No')
			return
	print('Yes')

def prt(l):
	return print(' '.join(l))

def rv():
	return map(int, input().split())

def rl(n):
	return [list(map(int, input().split())) for _ in range(n)]
if sys.hexversion == 50594544:
	sys.stdin = open('test.txt')
solve()


import sys
n = int(input())
a = list(map(int, input().split()))
even = a[::2]
odd = a[1::2]
ans = 0
if n == 2 and len(set(a)) == 1:
	ans = 1
if len(even) != len(set(even)) or len(odd) != len(set(odd)):
	ans = 1
if n < 7:
	kl = [i for i in range(n)]
	for i in range(6 * 120):
		if kl == a:
			print('Yes')
			sys.exit(0)
		else:
			for j in range(n):
				if j % 2 == 0:
					a[j] += 1
					a[j] %= n
				else:
					a[j] -= 1
					a[j] %= n
	print('No')
	sys.exit(0)
de = 0

def rotdiff(x, y):
	if (x + 2) % n == y:
		return True
	return False

def nordiff(x, y):
	if (x - 2) % n == y:
		return True
	return False
if ans != 1:
	for i in range(len(even) - 1):
		if de == 0:
			if nordiff(even[i], even[i + 1]):
				de = 1
			elif rotdiff(even[i], even[i + 1]):
				de = -1
			else:
				ans = 1
				break
		elif de == 1:
			if not nordiff(even[i], even[i + 1]):
				ans = 1
		elif not rotdiff(even[i], even[i + 1]):
			ans = 1
	de = 0
	for i in range(len(odd) - 1):
		if de == 0:
			if nordiff(odd[i], odd[i + 1]):
				de = 1
			elif rotdiff(odd[i], odd[i + 1]):
				de = -1
			else:
				ans = 1
				break
		elif de == 1:
			if not nordiff(odd[i], odd[i + 1]):
				ans = 1
		elif not rotdiff(odd[i], odd[i + 1]):
			ans = 1
print('No' if ans else 'Yes')


n = int(input())
a = list(map(int, input().split()))
tmp = []
for i in range(n):
	tmp.append(i)
for _ in range(n):
	for i in range(n):
		if i % 2 == 0:
			a[i] = (a[i] + 1) % n
		else:
			a[i] = (a[i] - 1 + n) % n
	if a == tmp:
		print('yes')
		exit(0)
print('no')


n = int(input())
a = list(map(int, input().split()))
good = True
b = (n - a[0]) % n
for i in range(n):
	if i % 2 == 0:
		if (n + i - a[i]) % n != b:
			good = False
	elif (a[i] - i + n) % n != b:
		good = False
if good:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
f1 = [0, -1, 1]
for i in range(n):
	f = 1
	for j in range(n):
		a[j] = (a[j] + f) % n
		f = f1[f]
	if a == list(range(n)):
		print('Yes')
		break
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
d = a[0] - n
for i in range(1, n):
	if (a[i] + d + n) % n != i:
		print('No')
		break
	d = -d
else:
	print('Yes')