The circle line of the Roflanpolis subway has $n$ stations.

There are two parallel routes in the subway. The first one visits stations in order $1 \to 2 \to \ldots \to n \to 1 \to 2 \to \ldots$ (so the next stop after station $x$ is equal to $(x+1)$ if $x < n$ and $1$ otherwise). The second route visits stations in order $n \to (n-1) \to \ldots \to 1 \to n \to (n-1) \to \ldots$ (so the next stop after station $x$ is equal to $(x-1)$ if $x>1$ and $n$ otherwise). All trains depart their stations simultaneously, and it takes exactly $1$ minute to arrive at the next station.

Two toads live in this city, their names are Daniel and Vlad.

Daniel is currently in a train of the first route at station $a$ and will exit the subway when his train reaches station $x$.

Coincidentally, Vlad is currently in a train of the second route at station $b$ and he will exit the subway when his train reaches station $y$.

Surprisingly, all numbers $a,x,b,y$ are distinct.

Toad Ilya asks you to check if Daniel and Vlad will ever be at the same station at the same time during their journey. In other words, check if there is a moment when their trains stop at the same station. Note that this includes the moments when Daniel or Vlad enter or leave the subway.


-----Input-----

The first line contains five space-separated integers $n$, $a$, $x$, $b$, $y$ ($4 \leq n \leq 100$, $1 \leq a, x, b, y \leq n$, all numbers among $a$, $x$, $b$, $y$ are distinct) — the number of stations in Roflanpolis, Daniel's start station, Daniel's finish station, Vlad's start station and Vlad's finish station, respectively.


-----Output-----

Output "YES" if there is a time moment when Vlad and Daniel are at the same station, and "NO" otherwise. You can print each letter in any case (upper or lower).


-----Examples-----
Input
5 1 4 3 2

Output
YES

Input
10 2 1 9 10

Output
NO



-----Note-----

In the first example, Daniel and Vlad start at the stations $(1, 3)$. One minute later they are at stations $(2, 2)$. They are at the same station at this moment. Note that Vlad leaves the subway right after that.

Consider the second example, let's look at the stations Vlad and Daniel are at. They are:   initially $(2, 9)$,  after $1$ minute $(3, 8)$,  after $2$ minutes $(4, 7)$,  after $3$ minutes $(5, 6)$,  after $4$ minutes $(6, 5)$,  after $5$ minutes $(7, 4)$,  after $6$ minutes $(8, 3)$,  after $7$ minutes $(9, 2)$,  after $8$ minutes $(10, 1)$,  after $9$ minutes $(1, 10)$. 

After that, they both leave the subway because they are at their finish stations, so there is no moment when they both are at the same station.

Difficulty: EASY

Solutions:
gi = lambda : list(map(int, input().strip().split()))
(n, a, x, b, y) = gi()
while a != x and b != y:
	a += 1
	if a > n:
		a = 1
	b -= 1
	if b <= 0:
		b = n
	if a == b:
		print('YES')
		return
print('NO')


(n, a, x, b, y) = map(int, input().split())
s1 = a
s2 = b
flag = False
while s1 != x and s2 != y:
	if s1 == s2:
		flag = True
		break
	if s1 != x:
		if s1 < n:
			s1 += 1
		else:
			s1 = 1
	if s2 != y:
		if s2 > 1:
			s2 -= 1
		else:
			s2 = n
	if s1 == s2:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline

def ii():
	return int(input())

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

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

def li():
	return list(input().rstrip())

def __starting_point():
	(n, a, x, b, y) = mi()
	while a % n != x % n and b % n != y % n:
		a += 1
		a %= n
		b -= 1
		b %= n
		if a % n == b % n:
			print('YES')
			break
	else:
		print('NO')
__starting_point()


(n, a, x, b, y) = map(int, input().split())
t1 = a
t2 = b
p = 0
while t1 != x and t2 != y:
	t1 = (t1 + 1) % n
	if t1 == 0:
		t1 = n
	t2 = t2 - 1
	if t2 == 0:
		t2 = n
	if t1 == t2:
		p = 1
		break
if p == 1:
	print('YES')
else:
	print('NO')


flag = True
(n, a, x, b, y) = list(map(int, input().split()))
for i in range(min((x - a) % n, (b - y) % n)):
	a = a + 1
	b = b - 1
	if a > n:
		a = 1
	if b == 0:
		b = n
	if a == b:
		print('YES')
		flag = False
		break
if flag:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
c = []
d = []
if a > x:
	for f in range(a, n + x + 1):
		if f > n:
			f = f - n
			c.append(f)
		else:
			c.append(f)
else:
	for f in range(a, x + 1):
		c.append(f)
if b < y:
	for g in range(b, y - 1 - n, -1):
		if g <= 0:
			g = n + g
			d.append(g)
		else:
			d.append(g)
else:
	for g in range(b, y - 1, -1):
		d.append(g)
if len(d) < len(c):
	p = 0
	while p < len(d):
		if c[p] == d[p]:
			print('YES')
			break
		p += 1
	else:
		print('NO')
else:
	p = 0
	while p < len(c):
		if c[p] == d[p]:
			print('YES')
			break
		p += 1
	else:
		print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
if a <= x:
	c = list(range(a, x + 1))
else:
	c = list(range(a, n + 1)) + list(range(1, x + 1))
if b >= y:
	d = list(range(y, b + 1))
	d.reverse()
else:
	e = list(range(1, b + 1))
	f = list(range(y, n + 1))
	e.reverse()
	f.reverse()
	d = e + f
n = min(len(c), len(d))
l = 0
for i in range(n):
	if c[i] == d[i]:
		l = l + 1
		break
if l == 1:
	print('YES')
else:
	print('NO')


from sys import stdin, exit
l = list(map(int, stdin.readline().split()))
(n, a, x, b, y) = (l[0], l[1], l[2], l[3], l[4])
(p1, p2) = (0, 0)
if a < x:
	p1 = x - a
else:
	p1 = n - (a - x)
if b > y:
	p2 = b - y
else:
	p2 = n - (y - b)
if a == b or x == y:
	print('YES')
else:
	k = []
	j = []
	for i in range(p1):
		a = a % n + 1
		k.append(a)
	for i in range(p2):
		b = b - 1
		if b == 0:
			b = n
		j.append(b)
	(s, d) = (0, 0)
	for i in k:
		s += 1
		d = 0
		for f in j:
			d += 1
			if i == f and s == d:
				print('YES')
				exit()
	print('NO')


I = lambda : list(map(int, input().split()))
(n, a, x, b, y) = I()
aa = 0
bb = 0
tf = 0
while 1:
	if a == b:
		tf = 1
		break
	a += 1
	b -= 1
	if a == x + 1:
		break
	if b == y - 1:
		break
	if a > n:
		a = 1
	if b < 1:
		b = n
print('YES' if tf else 'NO')


(n, a, x, b, y) = list(map(int, input().split()))
for i in range(min(x - a if x - a > 0 else n - a + x, b - y if b - y > 0 else b + n - y) + 1):
	if a == b:
		print('YES')
		exit()
	a += 1
	if a > n:
		a = 1
	b -= 1
	if b < 1:
		b = n
print('NO')


(n, a, x, b, y) = map(int, input().split())
lol = 0
i = 0
l1 = []
l2 = []
while a != x:
	l1.append(a)
	a += 1
	if a > n:
		a = 1
	if a == x:
		l1.append(a)
i = 0
while b != y:
	l2.append(b)
	b -= 1
	if b <= 0:
		b = n
	if b == y:
		l2.append(b)
for i in range(min(len(l1), len(l2))):
	if l1[i] == l2[i]:
		lol = 1
if lol == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
(i, j) = (a, b)
while i != x and j != y:
	i = i + 1
	if i == n + 1:
		i = 1
	j = j - 1
	if j == 0:
		j = n
	if i == j:
		exit(print('YES'))
print('NO')


(n, a, x, b, y) = map(int, input().split())
flag = 0
while a != x and b != y:
	a = (a + 1) % n
	if b - 1 == 0:
		b = n
	else:
		b = (b - 1) % n
	if a == 0:
		a = n
	if a == b:
		flag = 1
		print('YES')
		break
if flag == 0:
	print('NO')


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from heapq import heapify, heappop, heappush
(n, a, x, b, y) = map(int, input().split())
p = dc(int)
q = dc(int)
c1 = 0
s = a
e = x
while c1 < n:
	p[s] = c1
	if s == x:
		break
	c1 += 1
	s += 1
	if s == n + 1:
		s = 1
	if c1 < n:
		p[s] = c1
		c1 += 1
		if s == x:
			break
		s += 1
		if s == n + 1:
			s = 1
c2 = 0
s = b
while c2 < n:
	q[s] = c2
	if s == y:
		break
	c2 += 1
	s -= 1
	if s == 0:
		s = n
	if c2 < n:
		q[s] = c2
		c2 += 1
		if s == y:
			break
		s -= 1
		if s == 0:
			s = n
f = 0
for i in range(1, n + 1):
	if p[i] == q[i] and p[i] != 0:
		f = 1
		break
if f:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
i = a
j = b
while True:
	if i == j:
		print('YES')
		exit()
	if i == x:
		break
	elif i == n:
		i = 1
	else:
		i += 1
	if j == y:
		break
	elif j == 1:
		j = n
	else:
		j -= 1
print('NO')


def getPos(t, init, vel, metrosize):
	finalPos = init + t * vel
	finalPos = finalPos % metrosize
	return finalPos
line = tuple(map(int, input().split(' ')))
(metrosize, initPosA, finalPosA, initPosB, finalPosB) = line
initPosA -= 1
initPosB -= 1
finalPosA -= 1
finalPosB -= 1
doShock = False
simulationOver = False
time = 0
while not simulationOver:
	posA = getPos(time, initPosA, +1, metrosize)
	posB = getPos(time, initPosB, -1, metrosize)
	if posA == finalPosA:
		simulationOver = True
	if posB == finalPosB:
		simulationOver = True
	if posA == posB:
		doShock = True
	time += 1
if doShock:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
z = False
for i in range(n):
	a += 1
	if a == n + 1:
		a = 1
	b -= 1
	if b == 0:
		b = n
	if a == b:
		z = True
		print('YES')
		break
	if a == x:
		break
	if b == y:
		break
if not z:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
while True:
	if a == x or b == y:
		break
	else:
		a += 1
		b -= 1
		if a > n:
			a = 1
		if b == 0:
			b = n
		if a == b:
			print('YES')
			exit(0)
print('NO')


s = [int(n) for n in input().split()]
n = s[0]
a = s[1]
x = s[2]
b = s[3]
l = 0
y = s[4]
while a != x and b != y:
	if a == n:
		a = 1
	else:
		a += 1
	if b == 1:
		b = n
	else:
		b -= 1
	if a == b:
		print('YES')
		l = 1
		break
if l == 0:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
x = x % n
y = y % n
for i in range(n):
	a = a % n
	b = b % n
	if a == b:
		print('YES')
		exit()
	if a == x or b == y:
		print('NO')
		exit()
	a = a + 1
	b = b - 1
print('NO')


def D(n, a, x, b, y):
	d = []
	v = []
	xx = a
	yy = b
	ans = 0
	while xx != x and yy != y:
		if yy == xx:
			print('YES')
			ans = 1
			break
		if xx == n:
			xx = 1
		else:
			xx = xx + 1
		if yy == 1:
			yy = n
		else:
			yy = yy - 1
		if yy == xx:
			print('YES')
			ans = 1
			break
	if ans == 0:
		print('NO')
l = list(map(int, input().split()))
D(l[0], l[1], l[2], l[3], l[4])


(n, a, x, b, y) = map(int, input().split())
s = 'NO'
while a != x and b != y:
	a += 1
	b -= 1
	if a > n:
		a = 1
	if b < 1:
		b = n
	if a == b:
		s = 'YES'
		break
print(s)


def solve(n, a, x, b, y):
	(train1, train2) = (a, b)
	while train1 != x and train2 != y:
		if train1 == train2:
			return True
		train1 = train1 + 1 if train1 < n else 1
		train2 = train2 - 1 if train2 > 1 else n
	return train1 == train2

def main():
	(n, a, x, b, y) = map(int, input().split())
	print('YES' if solve(n, a, x, b, y) else 'NO')
main()


(n, a, x, b, y) = map(int, input().split())
ok = False
while a != b and a != x and (b != y):
	if a == n:
		a = 1
	else:
		a += 1
	if b == 1:
		b = n
	else:
		b -= 1
	if a == b:
		print('YES')
		ok = True
if ok == False:
	if a == b:
		print('YES')
	else:
		print('NO')


(n, a, x, b, y) = map(int, input().split())
ans = False
for i in range(n):
	if a == b:
		ans = True
	if a == x or b == y:
		break
	a += 1
	b -= 1
	if a > n:
		a = 1
	if b == 0:
		b = n
print('YES' if ans else 'NO')


(n, a, x, b, y) = map(int, input().split())
join = False
for k in range(min((x - a) % n, (b - y) % n) + 1):
	if a == b:
		join = True
	a += 1
	a %= n
	b -= 1
	b %= n
if join:
	print('YES')
else:
	print('NO')


s = input().split()
n = int(s[0])
a = int(s[1])
x = int(s[2])
b = int(s[3])
y = int(s[4])
t1 = (x - a) % n
t2 = (b - y) % n
t = min([t1, t2])
z = 0
for i in range(1, t + 1):
	if a == n:
		a = 1
	else:
		a += 1
	if b == 1:
		b = n
	else:
		b -= 1
	if a == b:
		z = 1
		break
if z == 0:
	print('NO')
else:
	print('YES')


inp = input()
lst = inp.split(' ')
n = int(lst[0])
a = int(lst[1])
x = int(lst[2])
b = int(lst[3])
y = int(lst[4])
st_d = []
st_v = []
i = a
st_d.append(i)
while True:
	i += 1
	if i > n:
		i = 1
	if i == x:
		st_d.append(i)
		break
	st_d.append(i)
i = b
st_v.append(i)
while True:
	i -= 1
	if i == 0:
		i = n
	if i == y:
		st_v.append(i)
		break
	st_v.append(i)
min_len = 0
if len(st_v) >= len(st_d):
	min_len = len(st_d)
else:
	min_len = len(st_v)
res = 'NO'
for j in range(min_len):
	if st_v[j] == st_d[j]:
		res = 'YES'
print(res)


import sys
(n, x, a, y, b) = input().split()
n = int(n)
a = int(a)
x = int(x)
b = int(b)
y = int(y)
x -= 1
y -= 1
b -= 1
a -= 1
while x != a and y != b:
	x = (x + 1) % n
	y = (n + y - 1) % n
	if x == y:
		print('YES')
		sys.exit()
print('NO')


(n, a, x, b, y) = map(int, input().split(' '))
yes = False
last = False
a_aux = a
b_aux = b
while True:
	a_aux = a % n
	b_aux = b % n
	if a_aux == 0:
		a = 0
		a_aux = n
	if b_aux == 0:
		b = n
		b_aux = n
	if a_aux == b_aux:
		print('YES')
		yes = True
		break
	if a == x or b == y:
		yes = False
		break
	b -= 1
	a += 1
	if last:
		break
	if a == x:
		last = True
if not yes:
	print('NO')


inp = list(map(int, input().split()))
n = inp[0]
a = inp[1]
x = inp[2]
b = inp[3]
y = inp[4]

def se(a, b, x, y, n, t):
	cx = x
	cy = y
	cross = 0
	if x < a:
		x = x + n
	if y > b:
		y = y - n
	t1 = int(abs(x - a))
	t2 = int(abs(y - b))
	if b < a:
		d = n - (a - b)
	else:
		d = b - a
	if d % 2 == 0:
		td = d / 2
	else:
		td = int(d / 2) + 1
	flag = 0
	if t1 < td or t2 < td:
		return 1
	else:
		cross = 1
		if b > a:
			if d % 2 == 0:
				flag = 0
			else:
				flag = 1
		elif n % 2 == 0:
			if d % 2 == 0:
				flag = 0
			else:
				flag = 1
		elif d % 2 == 0:
			flag = 0
		else:
			flag = 1
	if flag == 0:
		return flag
	if t == 2:
		return flag
	if cross == 1:
		a = a + td
		if a > n:
			a = a - n
		b = b - td
		if b < 1:
			b = b + n
		a = int(a)
		b = int(b)
		cx = int(cx)
		cy = int(cy)
		return se(a, b, cx, cy, n, 2)
flag = se(a, b, x, y, n, 1)
if flag == 0:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
if a > x:
	difa = n - a + x
else:
	difa = x - a
if b < y:
	difb = n - y + b
else:
	difb = b - y
x = 0
for i in range(min(difa, difb) + 1):
	if a == b:
		print('YES')
		x = 1
		break
	else:
		if a == x or b == y:
			break
		if a < n:
			a = a + 1
		elif a == n:
			a = 1
		if b > 1:
			b -= 1
		elif b == 1:
			b = n
if x == 0:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
set1 = set()
set2 = set()
if x < a:
	t1 = n - a + x % n + 1
else:
	t1 = x - a + 1
if b < y:
	t2 = b + n - y + 1
else:
	t2 = b - y + 1
for i in range(t1):
	k = (i, a)
	set1.add(k)
	if a == n:
		a = 1
	else:
		a += 1
for i in range(t2):
	k = (i, b)
	set2.add(k)
	if b == 1:
		b = n
	else:
		b -= 1
c = len(set1.intersection(set2))
if c != 0:
	print('YES')
else:
	print('NO')


(n, d, dd, v, vd) = [int(x) for x in input().split()]
if dd < d:
	dd += n
if vd > v:
	vd -= n
i = d - 1
j = v - 1
dd -= 1
vd -= 1
found = 0
while i <= dd and j >= vd:
	if i % n == j % n:
		print('YES\n')
		found = 1
		break
	else:
		i += 1
		j -= 1
if found == 0:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
a1 = [*range(n + 1)]
a2 = [*range(n + 1)]
a2.reverse()
a1.pop(0)
a2.pop(n)
for i in range(a - 1):
	a1.append(a1.pop(0))
for i in range(n - b):
	a2.append(a2.pop(0))
k = a1.index(x)
l = a2.index(y)
z = min(k, l)
ch = 0
for i in range(z + 1):
	if a1[i] == a2[i]:
		ch = 1
print('YES' if ch == 1 else 'NO')


def dist1(stations, start, end):
	count = 0
	while start != end:
		start += 1
		count += 1
		if start == stations + 1:
			start = 1
	return count

def dist2(stations, start, end):
	count = 0
	while start != end:
		start -= 1
		count += 1
		if start == 0:
			start = stations
	return count
inputVal = input('').split(' ')
stations = inputVal[0]
start1 = inputVal[1]
end1 = inputVal[2]
start2 = inputVal[3]
end2 = inputVal[4]
try:
	stations = int(stations)
	start1 = int(start1)
	end1 = int(end1)
	start2 = int(start2)
	end2 = int(end2)
except ValueError:
	print('Error: non-integer input.')
	exit()
diff = min(dist1(stations, start1, end1), dist2(stations, start2, end2))
while diff > 0:
	start1 += 1
	if start1 == stations + 1:
		start1 = 1
	start2 -= 1
	if start2 == 0:
		start2 = stations
	if start1 == start2:
		print('YES')
		exit()
	diff -= 1
print('NO')


msg = list(map(int, input().split()))
n = msg[0]
a = msg[1]
x = msg[2]
b = msg[3]
y = msg[4]
p = a
q = b
m = 0
while True:
	if p == q:
		m = 1
		break
	p = p + 1
	q = q - 1
	if p > n:
		p = 1
	if q < 1:
		q = n
	if p == q:
		m = 1
		break
	if p == x:
		break
	if q == y:
		break
if m == 0:
	print('NO')
else:
	print('YES')


(n, a, x, b, y) = map(int, input().split())
d = a
v = b
for i in range(n):
	d = d + 1
	if d > n:
		d = 1
	v = v - 1
	if v == 0:
		v = n
	if v == d:
		ret = 'YES'
		break
	if v == y or d == x:
		ret = 'NO'
		break
print(ret)


from sys import stdin
input = stdin.readline
(n, a, x, b, y) = list(map(int, input().split()))
(c1, c2) = (a, b)
while c1 != x and c2 != y:
	if c1 < n:
		c1 += 1
	else:
		c1 = 1
	if c2 > 1:
		c2 -= 1
	else:
		c2 = n
	if c1 == c2:
		print('YES')
		break
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
a -= 1
x -= 1
b -= 1
y -= 1
X = 1
while X:
	if a == b:
		print('YES')
		break
	if a == x or b == y:
		print('NO')
		break
	a = (a + 1) % n
	b = abs(b - 1 + n) % n


(n, a, x, b, y) = list(map(int, input().strip().split(' ')))
a -= 1
b -= 1
x -= 1
y -= 1
res = 'NO'
if x < a:
	x += n
if y > b:
	b += n
while a != x and b != y:
	a += 1
	b -= 1
	if a % n == b % n:
		res = 'YES'
		break
print(res)


(n, a, x, b, y) = map(int, input().split())
s = list(range(1, n + 1)) + list(range(1, n + 1))
fw = a - 1
bw = n + b - 1
f = 0
for i in range(n):
	if (s[fw + i] == x or s[bw - i] == y) and s[fw + i] != s[bw - i]:
		f = 0
		break
	elif s[fw + i] == s[bw - i]:
		f = 1
		break
if f:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
a -= 1
x -= 1
b -= 1
y -= 1
daniel = []
vlad = []
i = a
while i != x:
	daniel.append(i)
	i = (i + 1) % n
daniel.append(x)
i = b
while i != y:
	vlad.append(i)
	i = (i - 1 + n) % n
vlad.append(y)
if any((u == v for (u, v) in zip(daniel, vlad))):
	print('YES')
else:
	print('NO')


import math
inp = list(map(int, input().split()))
(n, a, x, b, y) = (inp[0], inp[1], inp[2], inp[3], inp[4])
x = int(x % n)
y = int(y % n)
kq = 0
while a != x and b != y:
	if a == b:
		kq = 1
		break
	if a == x or b == y:
		break
	a = int((a + 1) % n)
	b = int((b - 1 + n) % n)
if a == b:
	kq = 1
if kq == 0:
	print('NO')
else:
	print('YES')


(n, a, x, b, y) = list(map(int, input().split()))
t = 200
while t > 0:
	if a == b:
		print('YES')
		exit()
	if a == x or b == y:
		break
	a += 1
	b -= 1
	t -= 1
	if b == 0:
		b = n
	if a == n + 1:
		a = 1
print('NO')


import collections, heapq, sys
(n, a, x, b, y) = map(int, sys.stdin.readline().rstrip().split(' '))
while True:
	if a == b:
		print('YES')
		sys.exit()
	if a == x or b == y:
		break
	a += 1
	b -= 1
	if a == n + 1:
		a = 1
	if b == 0:
		b = n
print('NO')


(n, a, x, b, y) = map(int, input().split())
while a != x and b != y and (a != b):
	if a == b:
		break
	a = a % n + 1
	b = b - 1 if b - 1 else n
print('YNEOS'[a != b::2])


def solve():
	(n, a, x, b, y) = [int(m) for m in input().split(' ')]
	if a == b:
		print('YES')
		return
	while a != x and b != y:
		a += 1
		b -= 1
		if a > n:
			a = 1
		if b < 1:
			b = n
		if a == b:
			print('YES')
			return
	print('NO')
solve()


def f(l):
	(n, a, x, b, y) = l
	al = list(range(a, x + 1, +1)) if x >= a else list(range(a, n + 1, +1)) + list(range(1, x + 1, +1))
	bl = list(range(b, y - 1, -1)) if y <= b else list(range(b, 0, -1)) + list(range(n, y - 1, -1))
	t = min(len(al), len(bl))
	return sum([al[i] == bl[i] for i in range(t)])
l = list(map(int, input().split()))
print('YES' if f(l) else 'NO')


from sys import stdin

def input():
	return stdin.readline().strip()
(n, a, x, b, y) = map(int, input().split())
flag = a == b
while not flag and a != x and (b != y):
	if a == n:
		a = 1
	else:
		a += 1
	if b == 1:
		b = n
	else:
		b -= 1
	if a == b:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


inp = [int(e) for e in input().split(' ')]
p = False
while inp[1] != inp[2] and inp[3] != inp[4]:
	inp[1] += 1
	inp[3] -= 1
	if inp[1] > inp[0]:
		inp[1] = 1
	if inp[3] <= 0:
		inp[3] = inp[0]
	if inp[3] == inp[1]:
		p = True
		break
if p:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
l = [i for i in range(1, n + 1)]
l1 = l * 2
l2 = l * 2
indexa = l1.index(a)
if x > a:
	indexx = l1.index(x)
else:
	indexx = [i for (i, n) in enumerate(l1) if n == x][1]
indexy = l2.index(y)
if b < y:
	indexb = [i for (i, n) in enumerate(l2) if n == b][1]
else:
	indexb = l2.index(b)
for _ in range(min(indexb - indexy, indexx - indexa)):
	indexb -= 1
	indexa += 1
	if l1[indexa] == l1[indexb]:
		print('YES')
		exit()
else:
	print('NO')


(n, a, x, b, y) = tuple(map(int, input().rstrip().split()))

def trains(n, a, x, b, y):
	while True:
		if a > n:
			a = 1
		if b < 1:
			b = n
		if a == b:
			return 'YES'
		if a == x:
			break
		if b == y:
			break
		a += 1
		b -= 1
	if a == b:
		return 'YES'
	return 'NO'
print(trains(n, a, x, b, y))


(n, a, x, b, y) = map(int, input().split())
first = True
second = True
while first and second:
	a += 1
	if a == n + 1:
		a = 1
	b -= 1
	if b == 0:
		b = n
	if a == b:
		print('YES')
		break
	if a == x:
		first = False
	if b == y:
		second = False
else:
	print('NO')


d = {}
(n, d['Daniel'], x, d['Vlad'], y) = [int(i) for i in input().split()]
meet = False
while d['Daniel'] != x and d['Vlad'] != y:
	d['Daniel'] += 1
	d['Daniel'] %= n
	if d['Daniel'] == 0:
		d['Daniel'] = n
	d['Vlad'] -= 1
	d['Vlad'] %= n
	if d['Vlad'] == 0:
		d['Vlad'] = n
	if d['Daniel'] == d['Vlad']:
		meet = True
if d['Daniel'] == d['Vlad']:
	meet = True
print('YES' if meet else 'NO')


(n, a, x, b, y) = map(int, input().split())
i = 1
test = 0
a = a - 1
b = b + 1
while True:
	a = a + i
	b = b - i
	if a == b:
		test = 1
		print('YES')
		break
	if a - x == 0:
		break
	elif b - y == 0:
		break
	if a == n:
		a = 0
	if b == 1:
		b = n + 1
if test == 0:
	print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
a -= 1
x -= 1
b -= 1
y -= 1
while True:
	if a == b:
		print('YES')
		break
	if a == x or b == y:
		print('NO')
		break
	a = (a + 1) % n
	b = (b - 1) % n


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	(n, a, x, b, y) = mp()
	c = 0
	while a != x and b != y:
		a = a + 1
		b = b - 1
		if a > n:
			a = 1
		if b < 1:
			b = n
		if a == b:
			c = 1
			break
	if c:
		print('YES')
	else:
		print('NO')
for _ in range(1):
	solve()


z = list(map(int, input().split()))
(n, a, x, b, y) = (z[0], z[1], z[2], z[3], z[4])
flag = 0
while a != x and b != y:
	if a == n:
		a = 1
	else:
		a = a + 1
	if b == 1:
		b = n
	else:
		b = b - 1
	if a == b:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


entrada = input().split()
n = int(entrada[0])
a = int(entrada[1])
x = int(entrada[2])
b = int(entrada[3])
y = int(entrada[4])
flag = 0
while a != x and b != y and (flag == 0):
	if a == b:
		print('YES')
		flag = 1
		break
	else:
		if a + 1 > n:
			a = 1
		else:
			a = a + 1
		if b - 1 == 0:
			b = n
		else:
			b = b - 1
if a == b and flag == 0:
	print('YES')
	flag = 1
if flag == 0:
	print('NO')


def inputSeperator(inputStr):
	return list(map(int, inputStr.split(' ')))
temp = inputSeperator(input())
n = temp[0]
a = temp[1]
x = temp[2]
b = temp[3]
y = temp[4]
if a < x:
	fList = list(range(a, x + 1))
else:
	fList = list(range(a, n + 1)) + list(range(1, x + 1))
if y < b:
	sList = list(range(b, y - 1, -1))
else:
	sList = list(range(b, 0, -1)) + list(range(n, y - 1, -1))
done = False
for i in range(min(len(fList), len(sList))):
	if fList[i] == sList[i]:
		done = True
print(('NO', 'YES')[done])


(n, a, x, b, y) = map(int, input().split())
if x > a:
	ap = list(range(a, x + 1))
else:
	ap = list(range(a, n + 1)) + list(range(1, x + 1))
if y < b:
	bp = list(range(b, y - 1, -1))
else:
	bp = list(range(b, 0, -1)) + list(range(n, y - 1, -1))
for i in range(0, 150):
	try:
		if ap[i] == bp[i]:
			print('YES')
			break
	except:
		continue
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split(' '))
arr1 = []
arr2 = []
if x > a:
	for i in range(a, x + 1):
		arr1.append(i)
else:
	for i in range(a, n + 1):
		arr1.append(i)
	for i in range(1, x + 1):
		arr1.append(i)
if b > y:
	for i in range(b, y - 1, -1):
		arr2.append(i)
else:
	for i in range(b, 0, -1):
		arr2.append(i)
	for i in range(n, y - 1, -1):
		arr2.append(i)
i = 0
c = min(len(arr1), len(arr2))
flag = False
while i < c:
	if arr1[i] == arr2[i]:
		flag = True
		break
	i += 1
if flag == True:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
while a != x and b != y:
	if a == n:
		a = 1
	else:
		a += 1
	if b == 1:
		b = n
	else:
		b -= 1
	if a == b:
		print('YES')
		exit()
else:
	print('NO')


(n, a, x, b, y) = [int(x) - 1 for x in input().split()]
n += 1
ever_equal = a == b
while a != x and b != y:
	if a != x:
		a = (a + 1) % n
	if b != y:
		b = (b - 1) % n
	ever_equal |= a == b
print('YES' if ever_equal else 'NO')


(n, a, x, b, y) = map(int, input().split())
while a != x and b != y:
	a = a % n + 1
	b = (b - 2) % n + 1
	if a == b:
		print('YES')
		exit()
	if a == x or b == y:
		break
print('NO')


def nextInFirst(i, n):
	if i < n:
		return i + 1
	return 1

def nextInSecond(i, n):
	if i > 1:
		return i - 1
	return n
(n, a, x, b, y) = map(int, input().split())
while 1:
	if a == b:
		print('YES')
		break
	if a == x or b == y:
		print('NO')
		break
	a = nextInFirst(a, n)
	b = nextInSecond(b, n)


def meet(n, a, x, b, y):
	while True:
		a = a % n + 1
		b = (b - 1) % n
		if b == 0:
			b = n
		if a == b:
			print('YES')
			break
		if (a == x) | (b == y):
			print('NO')
			break
(n, a, x, b, y) = input().rstrip().split(' ')
(n, a, x, b, y) = (int(n), int(a), int(x), int(b), int(y))
meet(n, a, x, b, y)


(n, a, x, b, y) = map(int, input().split())
m1 = []
m2 = []
while a != x:
	m1.append(a)
	a += 1
	if a > n:
		a = 1
while b != y:
	m2.append(b)
	b -= 1
	if b < 1:
		b = n
m1.append(a)
m2.append(b)
b = False
for i in range(min(len(m1), len(m2))):
	if m1[i] == m2[i]:
		b = True
		break
if b:
	print('YES')
else:
	print('NO')


import sys
import math
from itertools import permutations
input = sys.stdin.readline
(n, a, x, b, y) = map(int, input().split())
flag = False
while True:
	if a == b:
		print('YES')
		flag = True
		break
	if a == x or b == y:
		break
	if a < n:
		a += 1
	else:
		a = 1
	if b > 1:
		b -= 1
	else:
		b = n
if not flag:
	print('NO')


(n, a, x, b, y) = input('').split()
n = int(n)
a = int(a)
b = int(b)
x = int(x)
y = int(y)
out = 'NO'
for i in range(n):
	if a == x or b == y:
		if a == b:
			out = 'YES'
		break
	elif a == b:
		out = 'YES'
		break
	else:
		if a == n:
			a = 1
		else:
			a += 1
		if b == 1:
			b = n
		else:
			b -= 1
print(out)


(n, a, x, b, y) = list(map(int, input().split()))
ans = False
while True:
	if a == b:
		ans = True
		break
	if a == x:
		break
	if b == y:
		break
	a += 1
	if a > n:
		a = 1
	b -= 1
	if b < 1:
		b = n
if ans:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = [int(x) for x in input().split()]
dan = a
vlad = b
meet = False
while dan != x and vlad != y:
	dan += 1
	if dan > n:
		dan = 1
	vlad -= 1
	if vlad < 1:
		vlad = n
	if vlad == dan:
		meet = True
		break
if meet:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
s = []
if a < x:
	for i in range(a, x + 1):
		s.append(i)
else:
	for i in range(a, n + 1):
		s.append(i)
	for i in range(1, x + 1):
		s.append(i)
ss = []
if y < b:
	for i in range(y, b + 1):
		ss.append(i)
	ss.reverse()
else:
	for i in range(y, n + 1):
		ss.append(i)
	for i in range(1, b + 1):
		ss.append(i)
	ss.reverse()
k = min(len(s), len(ss))
for i in range(k):
	if ss[i] == s[i]:
		print('YES')
		break
else:
	print('NO')


o = input().split()
n = int(o[0])
x = int(o[1])
m = int(o[2])
y = int(o[3])
z = int(o[4])
par = 'NO'
while (x != -1 and y != -1) and par == 'NO':
	if x == y:
		par = 'YES'
	if x == m:
		x = -1
	else:
		x += 1
	if y == z:
		y = -1
	else:
		y -= 1
	if x == n + 1:
		x = 1
	if y == 0:
		y = n
print(par)


(n, a, x, b, y) = map(int, input().split())
f = 0
x1 = min((x - a + n) % n, (b - y + n) % n)
while x1:
	if a >= n:
		a = a + 1 - n
	else:
		a = a + 1
	if b <= 1:
		b = b + n - 1
	else:
		b = b - 1
	if a == b:
		f = 1
		break
	x1 = x1 - 1
if f == 0:
	print('NO')
else:
	print('YES')


(n, a, x, b, y) = map(int, input().split())
i = 1
curD = a
curV = b
while 1:
	if curD == curV:
		print('YES')
		break
	if curD == x or curV == y:
		print('NO')
		break
	if curD == n:
		curD = 1
	else:
		curD += 1
	if curV == 1:
		curV = n
	else:
		curV -= 1


(n, a, x, b, y) = map(int, input().split())
First = []
if x >= a:
	for i in range(a, x + 1):
		First.append(i)
else:
	for i in range(a, n + 1):
		First.append(i)
	for i in range(1, x + 1):
		First.append(i)
Second = []
if y <= b:
	for i in range(b, y - 1, -1):
		Second.append(i)
else:
	for i in range(b, 0, -1):
		Second.append(i)
	for i in range(n, y - 1, -1):
		Second.append(i)
flag = 1
for i in range(min(len(First), len(Second))):
	if First[i] == Second[i]:
		print('YES')
		flag = 0
		break
if flag:
	print('NO')


(n, a, x, b, y) = input().split()
meet = False
n = int(n)
a = int(a)
x = int(x)
b = int(b)
y = int(y)
while a != x and b != y:
	if a == b:
		break
	a += 1
	b -= 1
	if a == n + 1:
		a = 1
	if b == 0:
		b = n
if a == b:
	meet = True
if meet == True:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())

def next_st1(a1, n):
	if a1 < n:
		return a1 + 1
	else:
		return 1

def next_st2(a2, n):
	if a2 > 1:
		return a2 - 1
	else:
		return n
(a1, b1) = (a, b)
flag = 0
while a1 != x and b1 != y:
	a1 = next_st1(a1, n)
	b1 = next_st2(b1, n)
	if a1 == b1:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
h = []
i = a
while i != x:
	h.append(i)
	i += 1
	if i == n + 1:
		i = 1
h.append(x)
i = b
k = []
while i != y:
	k.append(i)
	i -= 1
	if i == 0:
		i = n
flg = 0
k.append(y)
for i in range(min(len(h), len(k))):
	if k[i] == h[i]:
		flg = 1
if flg:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
t = 2 * min((x - a) % n, (b - y) % n) - (b - a) % n
print('YNEOS'[n % 2 < 1 or n > t if t % 2 else 0 > t::2])


(n, a, x, b, y) = map(int, input().split())
p = []
t1 = 1
while a != x:
	p.append(a)
	if a == n:
		a = 0
	a += 1
	t1 += 1
p.append(x)
q = []
t2 = 1
while b != y:
	q.append(b)
	if b == 1:
		b = n + 1
	b -= 1
	t2 += 1
q.append(y)
u = 0
for i in range(min(t1, t2)):
	if p[i] == q[i]:
		print('YES')
		u = 1
		break
if u == 0:
	print('NO')


a = list(map(int, input().split()))
k = 0
i = a[1]
j = a[3]
n = a[0]
while 1:
	if i == j:
		k = 1
		break
	if i == a[2] or j == a[4]:
		break
	i = (i + 1) % n
	j = (j - 1) % n
	if i == 0:
		i = n
	if j == 0:
		j = n
if k == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
curr = [a, b]
forward = [int(i) for i in range(1, n + 1)] * 2
backward = [int(i) for i in range(n, 0, -1)] * 2
ai = forward.index(curr[0])
bi = backward.index(curr[1])
found = False
count = 0
while not found and count < n:
	if curr[0] == curr[1]:
		found = True
		ans = 'YES'
	elif curr[0] == x or curr[1] == y:
		break
	else:
		curr[0] = forward[ai + 1]
		curr[1] = backward[bi + 1]
		ai += 1
		bi += 1
		count += 1
if not found:
	ans = 'NO'
print(ans)


(n, a, x, b, y) = list(map(int, input().split()))
a -= 1
b -= 1
x -= 1
y -= 1
(t1, t2) = (a, b)
ans = 'NO'
while t1 != x and t2 != y:
	if t1 == t2:
		ans = 'YES'
		break
	t1 = (t1 + 1) % n
	t2 = (t2 - 1) % n
if ans == 'YES' or t1 == t2:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = [int(t) for t in input().split(' ')]
a -= 1
x -= 1
b -= 1
y -= 1
i = a
j = b
good = False
while i is not None and b is not None and (not good):
	if i is not None:
		i = (i + 1) % n
	if j is not None:
		j = (j - 1 + n) % n
	good = i == j
	if i == x:
		i = None
	if j == y:
		j = None
print('YES' if good else 'NO')


(n, a, x, b, y) = map(int, input().split())
flag1 = 0
flag2 = 0
flag3 = 0
curr1 = a - 1
curr2 = b - 1
x -= 1
y -= 1
while not (flag1 == 1 and flag2 == 1):
	if curr1 == curr2 and flag1 == 0 and (flag2 == 0):
		flag3 = 1
		break
	if curr1 == x:
		flag1 = 1
	if curr2 == y:
		flag2 = 1
	curr1 = (curr1 + 1) % n
	curr2 = (curr2 - 1) % n
if flag3 == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
ai = [0] * n
bi = [0] * n
num = a - 1
i = 0
while num != x - 1:
	ai[num] = i
	num += 1
	num %= n
	i += 1
ai[num] = i
num = b - 1
i = 0
while num != y - 1:
	bi[num] = i
	num -= 1
	num %= n
	i += 1
bi[num] = i
ans = [ai[i] == bi[i] and ai[i] > 0 and (bi[i] > 0) for i in range(n)]
if max(ans):
	print('YES')
else:
	print('NO')


R = lambda : map(int, input().split())
(n, a, x, b, y) = R()
while True:
	if a == b:
		print('YES')
		exit()
	if a == x or b == y:
		print('NO')
		exit()
	a += 1
	b -= 1
	if a == n + 1:
		a = 1
	if b == 0:
		b = n


(n, a, x, b, y) = map(int, input().split())
(g, h, k) = (a, b, 0)
while g != h and g != x and (h != y):
	g += 1
	h -= 1
	if g == n + 1:
		g = 1
	if h == 0:
		h = n
print(['NO', 'YES'][g == h])


def main():
	(n, a, x, b, y) = map(int, input().split())
	(a, x, b, y) = (a % n, x % n, b % n, y % n)
	while a != x and b != y:
		if a == b:
			print('YES')
			return
		a = (a + 1) % n
		b = (b - 1) % n
	if a == b:
		print('YES')
	else:
		print('NO')
main()


nums = [int(r) for r in input().split()]
n = nums[0]
a = nums[1]
x = nums[2]
b = nums[3]
y = nums[4]
aDone = False
bDone = False
pos = False
for i in range(min((x - a) % n, (b - y) % n) + 1):
	if (a - b) % n == 0:
		pos = True
	if (a - x) % n == 0:
		aDone = True
	if (b - y) % n == 0:
		bDone = True
	if aDone == False:
		a += 1
	if bDone == False:
		b -= 1
if pos == True:
	print('YES')
else:
	print('NO')


for _ in range(1):
	(n, a, x, b, y) = map(int, input().split())
	flag = False
	while True:
		if a < n:
			a += 1
		else:
			a = 1
		if b > 1:
			b -= 1
		else:
			b = n
		if a == b:
			flag = True
			break
		if a == x or b == y:
			break
	if flag == True:
		print('YES')
	else:
		print('NO')


(n, a, x, b, y) = map(int, input().split())
if x >= a:
	l = [q for q in range(a, x + 1)]
else:
	l = [q for q in range(a, n + 1)]
	for q in range(1, x + 1):
		l.append(q)
if y <= b:
	k = [q for q in range(b, y - 1, -1)]
else:
	k = [q for q in range(b, 0, -1)]
	for q in range(n, y - 1, -1):
		k.append(q)
for z in range(min(len(l), len(k))):
	if l[z] == k[z]:
		n = 0
		break
print(['NO', 'YES'][n == 0])


import sys
input = sys.stdin.readline

class Problem:

	def __init__(self):
		pass

	def solve(self):
		print(self._solve())

	def _solve(self):
		(n, a, x, b, y) = [int(item) for item in input().split()]
		a -= 1
		b -= 1
		x -= 1
		y -= 1
		if a == b:
			return 'YES'
		for i in range(n):
			a = (a + 1) % n
			b = (b - 1) % n
			if a == b:
				return 'YES'
			if b == y or a == x:
				break
		return 'NO'

def main():
	problem = Problem()
	problem.solve()
main()


(n, a, x, b, y) = map(int, input().split())
st = []
for i in range(1, n + 1):
	st.append(i)
ai = a
bi = b
f = 0
while ai != x and bi != y:
	if ai == n:
		ai = 1
	else:
		ai = ai + 1
	if bi == 1:
		bi = n
	else:
		bi = bi - 1
	if ai == bi:
		print('YES')
		f = 1
		break
if f == 0:
	print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
if x < a:
	needa = n - a + x
else:
	needa = x - a
if y > b:
	needb = b + (n - y)
else:
	needb = b - y
while a != x and b != y and (a != b):
	if a + 1 > n:
		a = 1
	else:
		a += 1
	if b - 1 < 1:
		b = n
	else:
		b -= 1
if a == b:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
t1 = x - a
if x < a:
	t1 += n
t2 = b - y
if b < y:
	t2 += n
if a == b:
	exit(print('YES'))
for i in range(min(t2, t1)):
	a += 1
	b -= 1
	if a > n:
		a = 1
	if b < 1:
		b = n
	if a == b:
		exit(print('YES'))
print('NO')


l = list(map(int, input().split()))
while l[1] != l[2] and l[3] != l[4]:
	if l[1] == l[3]:
		print('YES')
		exit()
	l[1] += 1
	if l[1] == l[0] + 1:
		l[1] = 1
	l[3] -= 1
	if l[3] == 0:
		l[3] = l[0]
print('NO' if l[1] != l[3] else 'YES')


def main():
	(n, a, x, b, y) = list(map(int, input().split()))
	same = False
	while True:
		if a != x:
			a += 1
		else:
			break
		if b != y:
			b -= 1
		else:
			break
		if a == n + 1:
			a = 1
		if b == 0:
			b = n
		if a == b:
			break
	if a == b:
		print('YES')
	else:
		print('NO')
main()


(n, a, x, b, y) = list(map(int, input().split()))
time = 0
flag = False
a_pos = a
b_pos = b
while True:
	if a_pos == b_pos:
		flag = True
		break
	if a_pos == x or b_pos == y:
		break
	a_pos += 1
	b_pos -= 1
	if a_pos == n + 1:
		a_pos = 1
	if b_pos == 0:
		b_pos = n
if flag:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
if a == b:
	print('YES')
else:
	flag = False
	A = x - a if x >= a else n - a + x
	B = b - y if b >= y else n - y + b
	for k in range(min(A, B)):
		a = a + 1 if a < n else 1
		b = b - 1 if b > 1 else n
		if a == b:
			flag = True
			print('YES')
			break
	if not flag:
		print('NO')


(n, a, x, b, y) = [int(x) for x in input().split()]
a -= 1
b -= 1
x -= 1
y -= 1
(la, lb) = ([], [])
while a % n != x:
	la.append(a % n)
	a += 1
la.append(x)
while b % n != y:
	lb.append(b % n)
	b -= 1
	if b < 0:
		b += n
lb.append(y)
flag = 0
for (i, j) in zip(la, lb):
	if i == j:
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
i = a
l = []
l.append(i)
while i != x:
	i = (i + 1) % n
	if i == 0:
		i = n
	l.append(i)
j = b
h = []
h.append(j)
while j != y:
	j = (j - 1) % n
	if j == 0:
		j = n
	h.append(j)
(i, j) = (0, 0)
f = 0
while i < len(l) and j < len(h):
	if l[i] == h[j]:
		f = 1
		break
	else:
		f = 0
	i += 1
	j += 1
if f == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
ans = 'NO'
if a == b:
	ans = 'YES'
while a != x and b != y:
	if a == n:
		a = 0
	a += 1
	if b == 1:
		b = n + 1
	b -= 1
	if a == b:
		ans = 'YES'
print(ans)


n = [int(i) for i in input().split()]
i = n[1] - 1
j = n[3] - 1
c = 0
x = 1
while x:
	if not (i != n[2] - 1 and j != n[4] - 1):
		x = 0
	if i == j:
		c = 1
		break
	i = (i + 1) % n[0]
	j = (j - 1) % n[0]
if c == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
a = a - 1
b = b - 1
x = x - 1
y = y - 1
res = False
while 1:
	if a == b:
		res = True
		break
	if a == x or b == y:
		break
	a = (a + 1) % n
	b = (n + b - 1) % n
if res:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = [int(x) for x in input().split(' ')]
a = a - 1
b = b - 1
y = y - 1
x = x - 1
res = False
while a != x and b != y:
	if a == b:
		res = True
		break
	a = (a + 1) % n
	b = (b - 1) % n
if res or a == b:
	print('YES')
else:
	print('NO')


def nex(x):
	if x == n:
		return 1
	return x + 1

def pre(x):
	if x == 1:
		return n
	return x - 1
(n, a, x, b, y) = map(int, input().split())
while a != x and b != y:
	a = nex(a)
	b = pre(b)
	if a == b:
		print('YES')
		exit()
print('NO')


(n, a, x, b, y) = map(int, input().split())
if x < a:
	i = n + (x - a + 1)
else:
	i = x - a + 1
if b < y:
	j = n + (b - y + 1)
else:
	j = b - y + 1
p = min(i, j)
k = 0
while k < p:
	if a == b:
		print('YES')
		exit()
	else:
		if a == n:
			a = 1
		else:
			a += 1
		if b == 1:
			b = n
		else:
			b -= 1
	k += 1
print('NO')


(n, a, x, b, y) = map(int, input().split())
for i in range(1, 100):
	if a == b:
		print('YES')
		break
	else:
		a = a + 1
		b = b - 1
		if b == 0:
			b = n
		if a == n + 1:
			a = 1
		if a == x or b == y:
			if a == b:
				print('YES')
				break
			else:
				print('NO')
				break


(n, a, x, b, y) = map(int, input().split())
t = 2 * min((x - a) % n, (b - y) % n)
d = (b - a) % n
print('YNEOS'[not (n % 2 and d + n <= t if d % 2 else d <= t)::2])


list1 = list(map(int, input().split()))
list2 = []
flag = 0
for i in range(list1[0]):
	list2.append(i + 1)
if list1[1] == list1[3]:
	print('YES')
for j in range(list1[0]):
	a = list1[1] + j
	if a > list1[0]:
		a = a - list1[0]
	if list2[a - 1] == list2[list1[3] - j - 1]:
		flag = 1
		break
	if list2[a - 1] == list1[2] or list2[list1[3] - j - 1] == list1[4]:
		break
if flag == 1:
	print('YES')
elif flag == 0:
	print('NO')


d = tuple(map(int, input().split()))
n = d[0]
a = d[1]
x = d[2]
b = d[3]
y = d[4]
ddd = False
while True:
	if a < n:
		a += 1
	else:
		a = 1
	if b > 1:
		b -= 1
	else:
		b = n
	if a == b:
		ddd = True
		break
	if a == x or b == y:
		break
if ddd:
	print('YES')
else:
	print('NO')


q = 1
for _ in range(q):
	(n, a, x, b, y) = map(int, input().split())
	first = []
	yy = x - a
	if x - a < 0:
		yy = x - a + n
	z = b - y
	if b - y < 0:
		z = b - y + n
	last = a
	first.append(last)
	for i in range(yy):
		if last == n:
			first.append(1)
			last = 1
		else:
			first.append(last + 1)
			last += 1
	second = []
	last = b
	second.append(last)
	for i in range(z):
		if last == 1:
			second.append(n)
			last = n
		else:
			second.append(last - 1)
			last -= 1
	flag = 0
	for i in range(min(len(first), len(second))):
		if first[i] == second[i]:
			print('YES')
			flag = 1
			break
	if flag == 0:
		print('NO')


(n, a, x, b, y) = map(int, input().split())
k = r = 0
a -= 1
b -= 1
x -= 1
y -= 1
while k < n:
	r |= a == b
	if a == x or b == y:
		break
	a = (a + 1) % n
	b = (b + n - 1) % n
print('NYOE S'[r::2])


(n, a, x, b, y) = map(int, input().split())
d = []
v = []
if x < a:
	pd = a
	while pd != x:
		if pd == n:
			pd = 1
			d.append(1)
		if pd == x:
			break
		pd += 1
		d.append(pd)
else:
	for i in range(a + 1, x + 1):
		d.append(i)
if y > b:
	pv = b
	while pv != y:
		if pv == 1:
			pv = n
			v.append(n)
		if pv == y:
			break
		pv -= 1
		v.append(pv)
else:
	for i in range(b - 1, y - 1, -1):
		v.append(i)
f = 0
for i in range(min(len(d), len(v))):
	if d[i] == v[i]:
		f = 1
if f == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = [int(x) for x in input().strip().split()]
f = []
i = a
while i != x:
	f.append(i)
	i = i + 1
	if i > n:
		i = i % n
f.append(x)
s = []
i = b
while i != y:
	s.append(i)
	i = i - 1
	if i < 1:
		i = n + i
s.append(y)
k = min(len(f), len(s))
flag = 0
for i in range(k):
	if f[i] == s[i]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
yes = False
d = a
v = b
while (d != x or v != y) and (not yes):
	if d != x:
		d += 1
		if d > n:
			d = 1
	else:
		break
	if v != y:
		v -= 1
		if v < 1:
			v = n
	else:
		break
	if d == v:
		yes = True
print('YES' if yes else 'NO')


line = input().split()
n = int(line[0])
a = int(line[1])
x = int(line[2])
b = int(line[3])
y = int(line[4])
answer = False
while True:
	if a == b:
		answer = True
		break
	if a == x or b == y:
		break
	if a == n:
		a = 1
	else:
		a += 1
	if b == 1:
		b = n
	else:
		b -= 1
if answer:
	print('YES')
else:
	print('NO')


(n, a, x, y, b) = map(int, input().split())
startingStations = [a, y]
endStations = [x, b]
meet = False
for i in range(n):
	startingStations[0] += 1
	startingStations[1] -= 1
	if startingStations[0] == n + 1:
		startingStations[0] = 1
	if startingStations[1] == 0:
		startingStations[1] = n
	if startingStations[0] == startingStations[1]:
		meet = True
	if startingStations[0] == endStations[0]:
		break
	if startingStations[1] == endStations[1]:
		break
if meet:
	print('YES')
else:
	print('NO')


(n, sd, ed, sv, ev) = map(int, input().split())
t_s_d = [(i, s % n) for (i, s) in enumerate(range(sd, ed + 1 if ed > sd else ed + n + 1))]
t_s_v = [(i, s % n) for (i, s) in enumerate(range(sv, ev - 1 if ev < sv else ev - n - 1, -1))]
if set(t_s_d) & set(t_s_v):
	print('YES')
else:
	print('NO')


w = str(input())
(n, a, x, b, y) = map(int, w.split())
i = a - 1
j = b - 1
while i != j and i != x - 1 and (j != y - 1):
	if i != n - 1 and j != 0:
		i += 1
		j -= 1
	elif i == n - 1 and j != 0:
		i = 0
		j -= 1
	elif i != n - 1 and j == 0:
		i += 1
		j = n - 1
	elif i == n - 1 and j == 0:
		i = 0
		j = n - 1
if i == j:
	print('YES')
else:
	print('NO')


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
(n, a, x, b, y) = map(int, input().split())
if a < x:
	dic = []
	for i in range(a, x + 1):
		dic.append(i)
else:
	dic = []
	for i in range(a, n + 1):
		dic.append(i)
	for i in range(1, x + 1):
		dic.append(i)
if b > y:
	val = []
	for i in range(b, y - 1, -1):
		val.append(i)
else:
	val = []
	for i in range(b, 0, -1):
		val.append(i)
	for i in range(n, y - 1, -1):
		val.append(i)
ch = 1
for i in range(min(len(val), len(dic))):
	if dic[i] == val[i]:
		print('YES')
		ch = 0
		break
if ch:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
p = a
t = []
while x != p:
	t.append(p)
	p += 1
	if p == n + 1:
		p = 1
t.append(x)
p = b
q = []
while p != y:
	q.append(p)
	p -= 1
	if p == 0:
		p = n
q.append(y)
d = 0
for i in range(min(len(t), len(q))):
	if t[i] == q[i]:
		print('YES')
		d += 1
		break
else:
	print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
pos_a = a
pos_b = b
while pos_a != x and pos_b != y:
	pos_a += 1
	pos_b -= 1
	if pos_a == n + 1 and pos_a != x:
		pos_a = 1
	if pos_b == 0 and pos_b != y:
		pos_b = n
	if pos_b == pos_a:
		print('YES')
		exit()
print('NO')


(n, a, x, b, y) = (int(x) for x in input().split(' '))
x = x % n
y = y % n
while True:
	a = (a + 1) % n
	b = (b - 1) % n
	if a == b:
		print('YES')
		break
	elif a == x or b == y:
		print('NO')
		break


from sys import stdin, setrecursionlimit
import heapq
import collections
setrecursionlimit(15000)
(n, a, x, b, y) = list(map(int, stdin.readline().split()))
i = a
j = b
flag = False
while True:
	if i == j:
		flag = True
		break
	if i == x or j == y:
		break
	else:
		i += 1
		if i > n:
			i = 1
		j -= 1
		if j == 0:
			j = n
if flag:
	print('YES')
else:
	print('NO')


(N, A, X, B, Y) = map(int, input().split())
TA = [0] * N
TB = [0] * N
for (j, a) in enumerate(range(A, 1000)):
	TA[(a - 1) % N] += j
	if (a - 1) % N == (X - 1) % N:
		break
for (j, b) in enumerate(range(B, -1000, -1)):
	TB[(b - 1) % N] += j
	if (b - 1) % N == (Y - 1) % N:
		break
for (a, b) in zip(TA, TB):
	if a and b and (a == b):
		print('YES')
		break
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())

def dx(n, a, x, b, y):
	per1 = lambda r: r + 1 if r < n else 1
	per2 = lambda r: r - 1 if r > 1 else n
	if a == b:
		return 'YES'
	while a != x and b != y:
		a = per1(a)
		b = per2(b)
		if a == b:
			return 'YES'
	return 'NO'
print(dx(n, a, x, b, y))


(n, a, x, b, y) = map(int, input().split())
d = a
v = b
while d != -1 or v != -2:
	if d == v:
		print('YES')
		exit(0)
	if d != x and d != -1:
		d += 1
		d %= n
		if d == 0:
			d = n
	else:
		d = -1
	if v != y and v != -2:
		v -= 1
		if v == 0:
			v = n
	else:
		v = -2
	if d == v:
		print('YES')
		exit(0)
if d != v:
	print('NO')
else:
	print('YES')


(n, a, x, b, y) = map(int, input().split())
l1 = []
l2 = []
if x < a:
	for i in range(a, n + 1):
		l1.append(i)
	for i in range(1, a):
		if i != x:
			l1.append(i)
		else:
			l1.append(i)
			break
else:
	for i in range(a, x + 1):
		l1.append(i)
if y > b:
	for i in range(0, b):
		l2.append(b - i)
	for i in range(0, n - b):
		if n - i != y:
			l2.append(n - i)
		else:
			l2.append(n - i)
			break
else:
	for i in range(0, b - y + 1):
		l2.append(b - i)
for i in range(0, n):
	if i < len(l1) and i < len(l2):
		if l1[i] == l2[i]:
			print('YES')
			quit()
	else:
		print('NO')
		quit()
print('NO')


l1 = [int(x) for x in input().split()]
(n, a, x, b, y) = (l1[0], l1[1], l1[2], l1[3], l1[4])
done = 0
while a != x and b != y:
	if a == b:
		done = 1
		break
	if a == n:
		a = 1
	else:
		a += 1
	if b == 1:
		b = n
	else:
		b -= 1
if done or a == b:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = input().strip().split()
n = int(n)
a = int(a)
x = int(x)
b = int(b)
y = int(y)
if a < x:
	distA = x - a
else:
	distA = n - a + x
if y < b:
	distB = b - y
else:
	distB = n - y + b
minimum = min(distA, distB)
for i in range(minimum):
	if a == n:
		a = 1
	else:
		a = a + 1
	if b == 1:
		b = n
	else:
		b = b - 1
	if a == b:
		print('YES')
		exit()
print('NO')


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
from functools import lru_cache

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
(n, a, x, b, y) = ilele()
n -= 1
a -= 1
x -= 1
b -= 1
y -= 1
for i in range(2 * n):
	if a == b:
		Y(1)
		exit(0)
	if a == x or b == y:
		Y(0)
		exit(0)
	else:
		a += 1
		b -= 1
		a %= n + 1
		if b < 0:
			b = n
Y(0)


import sys
(n, a, x, b, y) = [*map(int, input().split())]
ilist = []
jlist = []
if x - a > 0:
	for i in range(a, x + 1, 1):
		ilist.append(i)
else:
	for i in range(a, n + 1, 1):
		ilist.append(i)
	for j in range(1, x + 1, 1):
		ilist.append(j)
if b - y > 0:
	for i in range(b, y - 1, -1):
		jlist.append(i)
else:
	for i in range(b, 0, -1):
		jlist.append(i)
	for j in range(n, y - 1, -1):
		jlist.append(j)
for k in range(min(len(ilist), len(jlist))):
	if ilist[k] == jlist[k]:
		print('YES')
		sys.exit()
print('NO')


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, OrderedDict
import math
import heapq

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
(n, a, x, b, y) = listIn()
if a > x:
	first = list(range(a, n + 1, 1)) + list(range(1, x + 1, 1))
else:
	first = list(range(a, x + 1))
if b < y:
	second = list(range(b, 0, -1)) + list(range(n, y - 1, -1))
else:
	second = list(range(b, y - 1, -1))
f = 0
for i in range(min(len(first), len(second))):
	if first[i] == second[i]:
		f = 1
		break
if f:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
if x > a:
	one = [k for k in range(a, x + 1)]
else:
	one = [a]
	while a != x:
		a = a + 1
		if a > n:
			a = 1
		one.extend([a])
if b > y:
	two = [k for k in range(b, y - 1, -1)]
else:
	two = [b]
	while b != y:
		b = b - 1
		if b < 1:
			b = n
		two.extend([b])
tup = zip(one, two)
flag = any((i == j for (i, j) in tup))
print(['NO', 'YES'][flag])


(n, a, b, x, y) = map(int, input().split())
flag = False
end1 = a
end2 = x
while end1 != b and end2 != y:
	if end1 == end2:
		flag = True
		break
	else:
		end1 += 1
		if end1 == n + 1:
			end1 = 1
		end2 -= 1
		if end2 == 0:
			end2 = n
if end1 == end2:
	flag = True
if flag:
	print('YES')
else:
	print('NO')


def train(n, a, x, b, y):
	while True:
		if a == b:
			return True
		if a == x:
			break
		if b == y:
			break
		a = a + 1 if a < n else 1
		b = b - 1 if b > 1 else n
	return False
(n, a, x, b, y) = map(int, input().split())
result = train(n, a, x, b, y)
if result:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())

def get_next_positive(a):
	return a % n + 1

def get_next_negative(b):
	return n if b == 1 else b - 1
while a != x and b != y:
	a = get_next_positive(a)
	b = get_next_negative(b)
	if a == b:
		print('YES')
		exit(0)
print('NO')


import sys

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

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

def main():
	(n, a, x, b, y) = get_ints()
	daniel = [-1] * (n + 1)
	if x >= a:
		t = 0
		for i in range(a, x + 1):
			daniel[i] = t
			t += 1
	else:
		t = 0
		for i in range(a, n + 1):
			daniel[i] = t
			t += 1
		for i in range(1, x + 1):
			daniel[i] = t
			t += 1
	vlad = [-1] * (n + 1)
	if y <= b:
		t = 0
		for i in range(b, y - 1, -1):
			vlad[i] = t
			t += 1
	else:
		t = 0
		for i in range(b, 0, -1):
			vlad[i] = t
			t += 1
		for i in range(n, y - 1, -1):
			vlad[i] = t
			t += 1
	ans = 'NO'
	for i in range(1, n + 1):
		if daniel[i] == vlad[i] and daniel[i] != -1:
			ans = 'YES'
			break
	print(ans)
main()


(n, a, x, b, y) = [int(i) for i in input().split()]
flag = False
for i in range(n + 1):
	a = a % n + 1
	b = (b - 2) % n + 1
	if a == b:
		flag = True
		break
	if a == x or b == y:
		break
if flag:
	print('YES')
else:
	print('NO')


def main():
	(n, a, x, b, y) = [int(i) for i in input().split()]
	for i in range(n + 2):
		if a == b:
			print('YES')
			break
		else:
			if a == x:
				print('NO')
				break
			if b == y:
				print('NO')
				break
			a = a % n + 1
			if b == 1:
				b = n
			else:
				b = b - 1
	else:
		print('NO')
main()


def main():
	(n, a, x, b, y) = map(int, input().split())
	flag = False
	for i in range(n):
		if a == b:
			flag = True
		if a == x:
			break
		if b == y:
			break
		a += 1
		b -= 1
		if a == n + 1:
			a = 1
		if b == 0:
			b = n
	if flag:
		print('YES')
	else:
		print('NO')
main()


z = [*map(int, input().split())]
for i in range(z[0] - 1):
	z[1] += 1
	z[3] -= 1
	if z[1] < 1:
		z[1] = z[0]
	elif z[1] > z[0]:
		z[1] = 1
	if z[3] > z[0]:
		z[3] = 1
	elif z[3] < 1:
		z[3] = z[0]
	if z[1] == z[3]:
		print('YES')
		exit(0)
	if z[1] == z[2] or z[3] == z[4]:
		break
print('NO')


import math

def inp_n():
	return int(input())

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

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

def is_odd(n):
	if n & 1:
		return True
	return False
(n, a, x, b, y) = inp_mul_num()
(ca, cb) = (a, b)
while True:
	if ca == cb:
		print('YES')
		break
	if ca == x or cb == y:
		print('NO')
		break
	if ca == n:
		ca = 1
	else:
		ca += 1
	if cb == 1:
		cb = n
	else:
		cb -= 1


(n, a, x, b, y) = list(map(int, input().split()))
Bool = True
Ans = False
while Bool:
	if a != n:
		a += 1
	else:
		a = 1
	if b != 1:
		b -= 1
	else:
		b = n
	if a == b:
		Ans = True
		break
	if a == x or b == y:
		break
if Ans == True:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
mini = (x - a) % n
if mini > (b - y) % n:
	mini = (b - y) % n
flag = 0
for i in range(mini):
	a += 1
	b -= 1
	if a > n:
		a = 1
	if b < 1:
		b = n
	if a == b:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
p = list(range(1, n + 1))
q = p[::-1]
p = p * 2
q = q * 2
s1 = []
s2 = []
i = p.index(a)
j = q.index(b)
for k in range(i, 2 * n):
	if p[k] != x:
		s1.append(p[k])
	else:
		s1.append(x)
		break
for k in range(j, 2 * n):
	if q[k] != y:
		s2.append(q[k])
	else:
		s2.append(y)
		break
for i in range(min(len(s1), len(s2))):
	if s1[i] == s2[i]:
		print('YES')
		break
else:
	print('NO')


from sys import stdin, stdout
from math import *

def main():
	(n, a, x, b, y) = [int(k) for k in stdin.readline().split()]
	while a != x and b != y:
		a = a + 1
		if a > n:
			a = 1
		b = b - 1
		if b == 0:
			b = n
		if a == b:
			stdout.write('YES')
			return 0
	stdout.write('NO')
	return 0
main()


(n, a, x, b, y) = list(map(int, input().split()))
z1 = a
z2 = b
import sys
while True:
	if z1 == z2:
		print('YES')
		sys.exit(0)
	if z1 == x or z2 == y:
		print('NO')
		sys.exit(0)
	z1 = z1 % n + 1
	if z2 == 1:
		z2 = n
	else:
		z2 -= 1


def first(a, n):
	a = a + 1
	if a > n:
		a = 1
	return a

def second(a, n):
	a = a - 1
	if a < 1:
		a = n
	return a
clist = list(map(int, input().strip().split()))
n = clist[0]
a = clist[1]
x = clist[2]
b = clist[3]
y = clist[4]
flag = False
while True:
	if a == b:
		flag = True
		break
	if a == x:
		break
	if b == y:
		break
	a = first(a, n)
	b = second(b, n)
if flag == True:
	print('YES')
else:
	print('NO')


def read_few_numbers():
	nums = map(int, input().split(' '))
	return nums

def simulate(n, a, x, b, y):
	while True:
		if a == b:
			return True
		if a == x:
			return False
		if b == y:
			return False
		a = a < n and a + 1 or 1
		b = b > 1 and b - 1 or n
(n, a, x, b, y) = read_few_numbers()
if simulate(n, a, x, b, y):
	print('YES')
else:
	print('NO')


def trains(n, a, b, c, d):
	for _ in range(n):
		if a == c:
			return 'YES'
		if a == b or c == d:
			break
		a += 1
		c -= 1
		if a > n:
			a = 1
		if c == 0:
			c = n
	return 'NO'
(n, a, b, c, d) = map(int, input().split())
print(trains(n, a, b, c, d))


(n, a, x, b, y) = map(int, input().split())
while a != x and b != y:
	a += 1
	if a > n:
		a = 1
	b -= 1
	if b < 1:
		b = n
	if a == b:
		print('YES')
		quit()
print('NO')


import math
from sys import stdin, stdout

def pnt(x):
	stdout.write(str(x) + '\n')

def pnt(x, end=' '):
	stdout.write(str(x) + end)

def reverse(s):
	str = ''
	for i in s:
		str = i + str
	return str
inp = lambda : int(stdin.readline())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, stdin.readline().split()))
sarr = lambda : list(map(str, stdin.readline().split()))
slst = lambda : list(sip())
arr2d = lambda N: [[int(x) for x in input().split()] for i in range(N)]
(n, a, x, b, y) = mulip()
d1 = []
d2 = []
if a > x:
	for i in range(a, n + 1):
		d1.append(i)
	for i in range(1, x + 1):
		d1.append(i)
else:
	for i in range(a, x + 1):
		d1.append(i)
if b < y:
	for i in range(b, 0, -1):
		d2.append(i)
	for j in range(n, y - 1, -1):
		d2.append(j)
else:
	for i in range(b, y - 1, -1):
		d2.append(i)
cnt = 0
if len(d1) > len(d2):
	for i in range(len(d2)):
		if d1[i] == d2[i]:
			cnt += 1
else:
	for i in range(len(d1)):
		if d1[i] == d2[i]:
			cnt += 1
if cnt == 0:
	print('NO')
else:
	print('YES')


(a, x1, b1, x2, b2) = map(int, input().split())
key = False
for i in range(a):
	x1 = x1 % a + 1
	x2 = (x2 - 2) % a + 1
	if x1 == x2:
		key = True
	if x1 == b1 or x2 == b2:
		break
if key:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
first = []
second = []
i = a
while i != x:
	i += 1
	if i > n:
		i = 1
	first.append(i)
i = b
while i != y:
	i -= 1
	if i < 1:
		i = n
	second.append(i)
f = 0
for i in range(min(len(first), len(second))):
	if first[i] == second[i]:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
r1 = list(range(1, n + 1))
r1.extend(r1)
r2 = list(range(n, 0, -1))
r2.extend(r2)
i = a - 1
j = n - b
while True:
	if r1[i] == r2[j]:
		print('YES')
		break
	if r1[i] == x or r2[j] == y:
		print('NO')
		break
	i += 1
	j += 1


(N, a, x, b, y) = [int(x) for x in input().split()]
while a != x and b != y:
	if a == b:
		print('YES')
		exit(0)
	if a != x:
		a += 1
	if a == N + 1:
		a = 1
	if b != y:
		b -= 1
	if b == 0:
		b = N
	if a == b:
		print('YES')
		exit(0)
print('NO')


(n, a, x, b, y) = (int(el) for el in input().split(' '))
ans = 'NO'
while True:
	if a == b:
		ans = 'YES'
		break
	if a == x or b == y:
		break
	a += 1
	if a == n + 1:
		a = 1
	b -= 1
	if b == 0:
		b = n
print(ans)


arr = [int(i) for i in input().split()]
n = arr[0]
a = arr[1]
x = arr[2]
b = arr[3]
y = arr[4]
g = 0
while a != x or b != y:
	a += 1
	b -= 1
	if a > n:
		a = 1
	if b == 0:
		b = n
	if b == a:
		g += 1
		break
	if a == x or b == y:
		break
if g == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
if x > a:
	da = x - a
else:
	da = x - a + n
if y < b:
	db = b - y
else:
	db = b - y + n
if b > a:
	dab = b - a
	if dab <= da and dab <= db and (y > b or x < a) and dab % 2:
		dab += n
else:
	dab = b - a + n
	if dab <= da and dab <= db and (y > b or x < a) and dab % 2:
		dab += n
if dab % 2:
	print('NO')
elif da >= dab / 2 and db >= dab / 2:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = input().split()
i = int(a)
j = int(b)
while i <= int(n) and j >= 0:
	if i == j:
		print('YES')
		break
	if i == int(x) or j == int(y):
		print('NO')
		break
	else:
		i = i + 1
		j = j - 1
	if i >= int(n) + 1:
		i = 1
	if j <= 0:
		j = int(n)


import os
import sys
from sys import stdin, stdout
from io import BytesIO, IOBase
mod = int(1000000000.0) + 7
intn = lambda : int(stdin.readline())
strs = lambda : stdin.readline()[:-1]
lstr = lambda : list(stdin.readline()[:-1])
mint = lambda : map(int, stdin.readline().split())
lint = lambda : list(map(int, stdin.readline().split()))
out = lambda x: stdout.write(str(x) + '\n')
out_ = lambda x: stdout.write(str(x) + ' ')

def main():
	(n, a, x, b, y) = mint()
	if a == b:
		out('YES')
	else:
		while a != x and b != y:
			a = a + 1 if a < n else 1
			b = b - 1 if b > 1 else n
			if a == b:
				out('YES')
				break
		else:
			out('NO')
main()


(n, a, x, b, y) = [int(i) for i in input().split()]
flag = 0
a1 = a
b1 = b
while a != x and b != y:
	if a < n:
		a += 1
	else:
		a = 1
	if b > 1:
		b -= 1
	else:
		b = n
	if a == b:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
a1 = [i for i in range(1, n + 1)] + [i for i in range(1, n + 1)]
a2 = [i for i in range(n, 0, -1)] + [i for i in range(n, 0, -1)]
i = a1.index(a)
j = a2.index(b)
if a1[i] == a2[j]:
	print('YES')
	exit()
while True:
	i += 1
	j += 1
	if a1[i] == a2[j]:
		print('YES')
		exit()
	if a1[i] == x or a2[j] == y:
		break
print('NO')


l = input().split()
n = int(l[0])
a = int(l[1])
x = int(l[2])
b = int(l[3])
y = int(l[4])
l1 = [a]
l2 = [b]
while l1[-1] != x:
	if l1[-1] == n:
		l1.append(1)
	else:
		z = l1[-1]
		l1.append(z + 1)
while l2[-1] != y:
	if l2[-1] == 1:
		l2.append(n)
	else:
		z = l2[-1]
		l2.append(z - 1)
poss = 0
for i in range(min(len(l1), len(l2))):
	if l1[i] == l2[i]:
		poss = 1
		break
if poss:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
A = list()
B = list()
A.append(a)
B.append(b)
while a != x:
	if a < n:
		a += 1
	else:
		a = 1
	A.append(a)
while b != y:
	if b > 1:
		b -= 1
	else:
		b = n
	B.append(b)
c = 0
i = 0
j = 0
while i < len(A) and j < len(B):
	if A[i] == B[j]:
		c = 1
		break
	i += 1
	j += 1
if c == 1:
	print('YES')
else:
	print('NO')


[n, a, x, b, y] = list(map(int, input().split()))
time1 = 0
time2 = 0
r1 = []
r2 = []
while a != x:
	r1.append(a)
	if a < n:
		a += 1
	else:
		a = 1
r1.append(a)
while b != y:
	r2.append(b)
	if b > 1:
		b -= 1
	else:
		b = n
r2.append(b)
i = 0
c = 0
while i < min(len(r1), len(r2)):
	if r1[i] == r2[i]:
		c = 1
		break
	i += 1
if c == 1:
	print('YES')
else:
	print('NO')


import sys, math
input = sys.stdin.readline
(n, a, x, b, y) = map(int, input().split())
flag = 0
a = a - 1
x = x - 1
b = b - 1
y = y - 1
if a == b:
	flag = 1
while a != x and b != y and (flag == 0):
	a = (a + 1) % n
	b = (b - 1) % n
	if a == b:
		flag = 1
if flag == 0:
	print('NO')
else:
	print('YES')


from sys import stdin, exit
(n, a, x, b, y) = map(int, stdin.readline().split())
while a != x and b != y:
	a += 1
	b -= 1
	if a == n + 1:
		a = 1
	if b == 0:
		b = n
	if a == b:
		print('YES')
		exit()
print('NO')


def main():
	(n, a, x, b, y) = map(int, input().strip().split())
	a -= 1
	x -= 1
	b -= 1
	y -= 1
	cf = a
	cs = b
	if a == b:
		print('YES')
		return
	while cf != x and cs != y:
		cf += 1
		cf %= n
		cs += n - 1
		cs %= n
		if cf == cs:
			print('YES')
			return
	print('NO')
	return

def __starting_point():
	main()
__starting_point()


X = list(map(int, input().split()))
n = X[0]
a = X[1] - 1
x = X[2] - 1
b = X[3] - 1
y = X[4] - 1
while 1:
	if a == b:
		print('YES')
		quit()
	if a == x or b == y:
		print('NO')
		quit()
	a = (a + 1) % n
	b = (b - 1 + n) % n


(n, a, x, b, y) = map(int, input().split())
d = a
e = b
f = 1
while d != x and e != y:
	d = 1 + d % n
	e = 1 + (e - 2) % n
	if e == d:
		print('YES')
		f = 0
		break
if f:
	print('NO')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, a, x, b, y) = f()
while a != x and b != y:
	a += 1
	b -= 1
	if a == b:
		exit(print('YES'))
	if a == n + 1:
		a = 1
	if b == 0:
		b = n
	if a == b:
		exit(print('YES'))
print('NO')


arr = list(map(int, input().split()))
a = arr[1]
x = arr[2]
b = arr[3]
y = arr[4]
flag = 1
while True:
	if a == b:
		break
	if a == x or b == y:
		flag = 0
		break
	if a == arr[0]:
		a = 1
	else:
		a = a + 1
	if b == 1:
		b = arr[0]
	else:
		b = b - 1
if flag:
	print('YES')
else:
	print('NO')


import sys
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
readl = lambda : list(map(int, sys.stdin.readline().split()))
readt = lambda : tuple(map(int, sys.stdin.readline().split()))
read = lambda : sys.stdin.readline().rstrip()
readi = lambda : int(read())
readmi = lambda : map(int, sys.stdin.readline().split())
readms = lambda : map(str, sys.stdin.readline().split())
s = readl()
n = s[0]
v = s[1]
vg = s[2]
d = s[3]
dg = s[4]
while v != vg and d != dg:
	if v < n:
		v += 1
	else:
		v = 1
	if d > 1:
		d -= 1
	else:
		d = n
	if v == d:
		print('YES')
		exit()
print('NO')


(n, a, x, b, y) = map(int, input().split())
l = [a]
l1 = [b]
while a != x:
	a += 1
	if a == n + 1:
		a = 1
	l.append(a)
while b != y:
	b -= 1
	if b == 0:
		b = n
	l1.append(b)
f = 'NO'
for i in range(min(len(l1), len(l))):
	if l1[i] == l[i]:
		f = 'YES'
print(f)


(n, a, x, b, y) = list(map(int, input().split()))
ok = 2
good = False
while 1:
	a = a + 1 if a < n else 1
	b = b - 1 if b > 1 else n
	if a == b:
		good = True
		break
	if a == x:
		break
	if b == y:
		break
if good:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
aa = a
bb = b
ans = ['YES', 'NO']
idex = 1
while 1:
	a += 1
	b -= 1
	if a == b:
		idex = 0
		break
	else:
		if a > n:
			a = 1
		if b < 1:
			b = n
		if a == x or b == y:
			if a == b:
				idex = 0
			break
	if a == b:
		idex = 0
		break
print(ans[idex])


L = [int(i) for i in input().split()]
n = L[0]
a = L[1]
x = L[2]
b = L[3]
y = L[4]
test = 0
while a != x and b != y:
	if a == b:
		test = 1
		break
	else:
		a += 1
		if a == n + 1:
			a = 1
		b -= 1
		if b == 0:
			b = n
	if a == b:
		test = 1
		break
if test == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
a -= 1
x -= 1
b -= 1
y -= 1
while a != x and b != y:
	if a == b:
		print('YES')
		raise SystemExit(0)
	a = (a + 1) % n
	b = (b - 1 + n) % n
if a == b:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = [int(i) for i in input().split()]
while a != x and b != y:
	a = (a - 1 + 1) % n + 1
	b = (b - 1 - 1) % n + 1
	if a == b:
		print('YES')
		exit()
print('NO')


(n, a, x, b, y) = list(map(int, input().strip().split()))
for _ in range(n):
	if a == b:
		print('YES')
		break
	if a == x or b == y:
		print('NO')
		break
	a = a + 1 if a != n else 1
	b = b - 1 if b != 1 else n


(n, a, x, b, y) = map(int, input().split())
first = (list(range(1, n + 1)) * 2)[a - 1:x if x > a else x + n]
second = (list(range(1, n + 1)) * 2)[y - 1:b if b > y else b + n][::-1]
print(('NO', 'YES')[int(any(map(lambda s: s[0] == s[1], zip(first, second))))])


class CircleMetro:

	def journey(self):
		met = False
		while not met and (not self.destination_reached()):
			met = self.move_daniel().move_vlad().meeting_done()
		if met == True:
			print('YES')
		else:
			print('NO')

	def meeting_done(self):
		return self.daniel_curr == self.vlad_curr

	def destination_reached(self):
		return self.daniel_curr == self.x or self.vlad_curr == self.y

	def move_daniel(self):
		self.daniel_curr = self.daniel_curr + 1
		if self.daniel_curr == self.n + 1:
			self.daniel_curr = 1
		return self

	def move_vlad(self):
		self.vlad_curr = self.vlad_curr - 1
		if self.vlad_curr == 0:
			self.vlad_curr = self.n
		return self

	def __init__(self, n, a, b, x, y):
		self.n = n
		(self.daniel_curr, self.vlad_curr) = (a, b)
		(self.a, self.b, self.x, self.y) = (a, b, x, y)
(n, a, x, b, y) = tuple(map(int, input().split(' ')))
metro = CircleMetro(n, a, b, x, y)
metro.journey()


(n, a, b, c, d) = map(int, input().split())
while a != b and c != d:
	if a == n:
		a = 1
	else:
		a += 1
	if c == 1:
		c = n
	else:
		c -= 1
	if a == c:
		print('YES')
		exit()
print('NO')


(n, a, x, b, y) = map(int, input().split())
ans = 'NO'
for i in range(n):
	if a == b:
		ans = 'YES'
		break
	elif a == x or b == y:
		break
	a += 1
	b -= 1
	if a > n:
		a = 1
	if b < 1:
		b = n
print(ans)


(n, a, x, b, y) = [int(i) for i in input().split()]
res = 0
while a != x and b != y:
	if a == n:
		a = 1
	else:
		a += 1
	if b == 1:
		b = n
	else:
		b -= 1
	if a == b:
		res += 1
		break
print('YES' if res == 1 else 'NO')


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
ans = 'NO'
(n, a, x, b, y) = RMI()
while a != x and b != y:
	a += 1
	b -= 1
	if a > n:
		a = 1
	if b < 1:
		b = n
	if a == b:
		ans = 'YES'
		break
print(ans)


from sys import stdin
input = stdin.readline
(n, a, x, b, y) = list(map(int, input().split()))
if a < x:
	s1 = list(range(a, x + 1))
else:
	s1 = list(range(a, n + 1)) + list(range(1, x + 1))
if b > y:
	s2 = list(range(b, y - 1, -1))
else:
	s2 = list(range(b, 0, -1)) + list(range(n, y - 1, -1))
for i in range(min(len(s1), len(s2))):
	if s2[i] == s1[i]:
		print('YES')
		break
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
if x >= a:
	k = x - a
	t = [a + i for i in range(0, k + 1)]
elif x < a:
	k = n - a + x + 1
	t = [a + i for i in range(0, n - a + 1)]
	t1 = [j for j in range(1, x + 1)]
	t = t + t1
if y <= b:
	k1 = b - y
	r = [i for i in range(b, y - 1, -1)]
elif y > b:
	k1 = n - b + y + 1
	r = [i for i in range(b, 0, -1)]
	r1 = [j for j in range(n, y - 1, -1)]
	r = r + r1
k = 0
for i in range(len(t)):
	if t[i] in r:
		for j in range(len(r)):
			if r[j] == t[i]:
				if i == j:
					k = 1
					print('YES')
					break
		if k == 1:
			break
if k == 0:
	print('NO')


(n, a, x, b, y) = list((int(h) for h in input().split()))
succ = False
while a != x and b != y:
	if a == b:
		succ = True
		break
	a += 1
	b -= 1
	if a > n:
		a = 1
	if b < 1:
		b = n
if succ or a == b:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
p1 = a
p2 = b
while True:
	if p1 == p2:
		flag = True
		break
	elif p1 == x or p2 == y:
		flag = False
		break
	else:
		p1 = p1 + 1
		if p1 == n + 1:
			p1 = 1
		p2 = p2 - 1
		if p2 == 0:
			p2 = n
if flag:
	print('YES')
else:
	print('NO')


ab = [int(x) for x in input().split(' ')]
(n, a, x, b, y) = (ab[0], ab[1], ab[2], ab[3], ab[4])
r = (b - a) % n
if x < a:
	sa = n - (a - x)
else:
	sa = x - a
if y > b:
	sb = n - (y - b)
else:
	sb = b - y
if r % 2 == 0:
	t = r // 2
	if t <= sa and t <= sb:
		print('YES')
	elif (r + n) % 2 == 0:
		t = (r + n) // 2
		if t <= sa and t <= sb:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
elif (r + n) % 2 == 0:
	t = (r + n) // 2
	if t <= sa and t <= sb:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
while 1:
	if a == b:
		print('YES')
		break
	elif a == x:
		print('NO')
		break
	elif b == y:
		print('NO')
		break
	if a == n:
		a = 1
	else:
		a += 1
	if b == 1:
		b = n
	else:
		b -= 1


line = input().rstrip().split()
n = int(line[0])
a = int(line[1]) - 1
b = int(line[2]) - 1
x = int(line[3]) - 1
y = int(line[4]) - 1
key = False
while a % n != b and x % n != y:
	if (a + 1) % n == (x - 1) % n:
		key = True
		break
	a += 1
	x -= 1
if key:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
l = [(a, b)]
while x != a and y != b:
	if a == n:
		a = 1
	else:
		a = a + 1
	if b == 1:
		b = n
	else:
		b = b - 1
	l.append((a, b))
	if a == b:
		break
flag = 0
for i in l:
	(p, q) = i
	if p == q:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = 1
for tt in range(t):
	(n, a, x, b, y) = map(int, sys.stdin.readline().split(' '))
	while 1:
		if a == x or b == y:
			break
		if a == b:
			break
		if a < n:
			a += 1
		else:
			a = 1
		if b > 1:
			b -= 1
		else:
			b = n
	if a == b:
		print('YES')
	else:
		print('NO')
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


from sys import stdin
(n, a, x, b, y) = map(int, stdin.readline().strip().split())
flag = False
flag1 = True
flag2 = True
while flag1 and flag2:
	if a == x:
		flag1 = False
	if b == y:
		flag2 = False
	if a == b:
		flag = True
	a += 1
	if a > n:
		a = 1
	b -= 1
	if b < 1:
		b = n
	if a == x:
		flag1 = False
	if b == y:
		flag2 = False
	if a == b:
		flag = True
if flag:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())

def danial(n, a, x):
	if a < x:
		arr = [i for i in range(a, x + 1)]
		return arr
	else:
		arr = [i for i in range(a, n + 1)]
		for j in range(1, x + 1):
			arr.append(j)
		return arr

def vlad(n, b, y):
	if b > y:
		arr = [i for i in range(b, y - 1, -1)]
		return arr
	else:
		arr = [i for i in range(b, 0, -1)]
		for j in range(n, y - 1, -1):
			arr.append(j)
		return arr
danial = danial(n, a, x)
vlad = vlad(n, b, y)
n1 = len(danial)
n2 = len(vlad)
n = min(n1, n2)

def ans():
	for k in range(n):
		if danial[k] == vlad[k]:
			return 1
	return 0
if ans() is 1:
	print('YES')
else:
	print('NO')


from math import *
(n, a, x, b, y) = map(int, input().split(' '))
i = a
j = b
while i != x and j != y:
	if i == j:
		print('YES')
		exit()
	i += 1
	if i == n + 1:
		i = 1
	j -= 1
	if j == 0:
		j = n
if i == j:
	print('YES')
else:
	print('NO')


a = list(map(int, input().split()))
n = a[0]
ds = a[1]
df = a[2]
vs = a[3]
vf = a[4]
while ds != vs and ds != df and (vs != vf):
	ds = ds + 1
	vs = vs - 1
	if ds == n + 1:
		ds = 1
	if vs == 0:
		vs = n
if ds == vs:
	print('YES')
else:
	print('NO')


def f(n, a, x, b, y):
	while True:
		if a + 1 == n + 1:
			a = 1
		else:
			a = a + 1
		if b - 1 == 0:
			b = n
		else:
			b = b - 1
		if a == b:
			return 'YES'
		if a == x or b == y:
			break
	return 'NO'
(n, a, x, b, y) = [int(i) for i in input().split()]
print(f(n, a, x, b, y))


z = [int(i) for i in input().split()]
n = z[0]
x = z[1]
a = z[2]
y = z[3]
b = z[4]
flag = 0
while True:
	if x == a and y == a or (y == b and x == b) or x == y:
		flag = 1
		break
	elif x == a or y == b:
		break
	else:
		if x == n:
			x = 1
		else:
			x += 1
		if y == 1:
			y = n
		else:
			y -= 1
if flag == 0:
	print('NO')
else:
	print('YES')


(n, a, x, b, y) = [int(i) for i in input().split()]
flag = False
while a != x and b != y:
	if a == x:
		a -= 1
	if b == y:
		b -= 1
	a += 1
	b -= 1
	if a == n + 1:
		a = 1
	if b == 0:
		b = n
	if a == b:
		flag = True
		break
if flag is True:
	print('YES')
else:
	print('NO')


import sys
ln = sys.stdin.readline().rstrip()
vals = ln.split()
for a in range(0, len(vals)):
	vals[a] = int(vals[a])
posA = vals[1]
posB = vals[3]
found = False
while posA != vals[2] and posB != vals[4]:
	if posA == posB:
		print('YES')
		found = True
		break
	posA += 1
	posB -= 1
	if posA > vals[0]:
		posA = 1
	if posB < 1:
		posB = vals[0]
	if posA == posB:
		print('YES')
		found = True
		break
if not found:
	print('NO')


def move(d, v):
	if d == n:
		d = 1
	else:
		d = d + 1
	if v == 1:
		v = n
	else:
		v = v - 1
	return (d, v)
s = input()
(n, a, x, b, y) = map(int, s.split(' '))
daniel = a
vlad = b
f = 0
while daniel != x and vlad != y:
	if daniel == vlad:
		f = 1
	(daniel, vlad) = move(daniel, vlad)
	if daniel == vlad:
		f = 1
if f == 0:
	print('NO')
else:
	print('YES')


(n, a, b, c, d) = map(int, input().split())
mapdaniel = {}
mapvlad = {}
mapdaniel[0] = a
mapvlad[0] = c
t = 1
t1 = 1
if a < b <= n:
	for i in range(a + 1, b + 1):
		mapdaniel[t] = i
		t += 1
elif b < a:
	for i in range(a + 1, n + 1):
		mapdaniel[t] = i
		t += 1
	for i in range(1, b + 1):
		mapdaniel[t] = i
		t += 1
if 1 <= d < c:
	for i in range(c - 1, d - 1, -1):
		mapvlad[t1] = i
		t1 += 1
elif d > c:
	for i in range(c - 1, 0, -1):
		mapvlad[t1] = i
		t1 += 1
	for i in range(n, d - 1, -1):
		mapvlad[t1] = i
		t1 += 1
ans = 0
for j in mapdaniel:
	p = mapvlad.get(j, 0)
	if p == mapdaniel[j]:
		ans = 1
if ans == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
found = 0
if a > x:
	l1 = list(range(a, n + 1)) + list(range(1, x + 1))
else:
	l1 = list(range(a, x + 1))
if b < y:
	l2 = list(range(b, 0, -1)) + list(range(n, y - 1, -1))
else:
	l2 = list(range(b, y - 1, -1))
for (e1, e2) in zip(l1, l2):
	if e1 == e2:
		found = 1
		break
print(['NO', 'YES'][found])


lne = [int(i) for i in input().split(' ')]
n = lne[0]
a = lne[1]
sa = a
x = lne[2]
b = lne[3]
sb = b
y = lne[4]
t = False
wds = ['NO', 'YES']
while True:
	if a == b:
		t = True
	a += 1
	b -= 1
	a = (a - 1) % n + 1
	b = (b + n - 1) % n + 1
	if a == b:
		t = True
	if a == x or b == y:
		break
print(wds[t])


from sys import stdin
from sys import stdout
(n, a, x, b, y) = map(int, stdin.readline().split())
flag = 0
while True:
	a = a + 1 if a < n else 1
	b = b - 1 if b > 1 else n
	if a == b:
		flag = 1
		break
	if a == x or b == y:
		break
if flag == 1:
	stdout.write('YES')
else:
	stdout.write('NO')


(N, A, X, B, Y) = map(int, input().split())
ok = False
while True:
	if A + 1 > N:
		A = 1
	else:
		A += 1
	if B > 1:
		B -= 1
	else:
		B = N
	if A == B:
		ok = True
		break
	if A == X or B == Y:
		break
if ok:
	print('YES')
else:
	print('NO')


nums = list(map(lambda x: int(x), input().split(' ')))
(n, a, x, b, y, ride, meet) = (nums[0], nums[1], nums[2], nums[3], nums[4], True, False)
(first, second) = (True, True)
while ride:
	if first:
		a += 1
		if a == n + 1:
			a = 1
		if a == x:
			first = False
	if second:
		b -= 1
		if b == 0:
			b = n
		if b == y:
			second = False
	if a == b:
		meet = True
	if not first:
		a = 0
	if not second:
		b = 0
	if not first and (not second):
		ride = False
if meet:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
while 1:
	if a == b:
		print('YES')
		quit()
	if a == x or b == y:
		print('NO')
		quit()
	if a != x:
		a += 1
	if b != y:
		b -= 1
	if a == n + 1:
		a = 1
	if b == 0:
		b = n


import sys
(n, a, x, b, y) = map(int, input().split())
status = True
while status:
	if a == b:
		print('YES')
		sys.exit()
	if a == x % n or b == y % n:
		status = False
	a = (a + 1) % n
	b = (b - 1) % n
print('NO')


def check(n, a, x, b, y):
	count = 0
	if a == b:
		return True
	z = True
	k = True
	while count < n and z and k:
		a += 1
		if a > n:
			a = 1
		b -= 1
		if b < 1:
			b = n
		if a == b:
			z = False
		if a == x or b == y:
			k = False
		count += 1
	return not z
m = list(map(int, input().strip().split()))
if check(m[0], m[1], m[2], m[3], m[4]):
	print('YES')
else:
	print('NO')


import math
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
(n, a, x, b, y) = li()
while a != x and b != y:
	if a < n:
		a += 1
	else:
		a = 1
	if b > 1:
		b -= 1
	else:
		b = n
	if a == b:
		print('YES')
		exit(0)
print('NO')


(n, a, x, b, y) = map(int, input().split())

def next_1(x):
	if x < n:
		return x + 1
	else:
		return 1

def next_2(x):
	if x > 1:
		return x - 1
	else:
		return n
answer = 'NO'
while a != x and b != y:
	if a == b:
		answer = 'YES'
	a = next_1(a)
	b = next_2(b)
if a == b:
	answer = 'YES'
print(answer)


(n, a, x, b, y) = map(int, input().split())
c = 0
d = 0
cnt = 0
while c != 1 and d != 1 and (cnt != n):
	cnt = cnt + 1
	if a < n:
		a = a + 1
	else:
		a = 1
	if b > 1:
		b = b - 1
	else:
		b = n
	if a == x or b == y:
		d = 1
	if a == b:
		c = 1
if c == 1:
	print('YES')
else:
	print('NO')


ls = list(map(int, input().split()))
c = 0
if ls[1] < ls[2] and ls[3] > ls[4]:
	s = min(ls[2] - ls[1], ls[3] - ls[4])
elif ls[1] >= ls[2] and ls[3] > ls[4]:
	s = min(ls[0] - (ls[1] - ls[2]), ls[3] - ls[4])
elif ls[1] < ls[2] and ls[3] <= ls[4]:
	s = min(ls[0] - (ls[4] - ls[3]), ls[2] - ls[1])
else:
	s = min(ls[0] - (ls[1] - ls[2]), ls[0] - (ls[4] - ls[3]))
for i in range(0, s + 1):
	if ls[1] == ls[3]:
		print('YES')
		c = 1
		break
	elif ls[1] == ls[0] or ls[3] == 1:
		if ls[1] == ls[0] and ls[3] != 1:
			ls[1] = 1
			ls[3] = ls[3] - 1
		elif ls[3] == 1 and ls[1] != ls[0]:
			ls[3] = ls[0]
			ls[1] = ls[1] + 1
		else:
			ls[1] = 1
			ls[3] = ls[0]
	else:
		ls[1] = ls[1] + 1
		ls[3] = ls[3] - 1
if c == 0:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
(f, p1, p2) = (1, a, b)
while p1 != x and p2 != y:
	(p1, p2) = ((p1 + 1) % n, (p2 - 1) % n)
	if p1 == 0:
		p1 = n
	if p2 == 0:
		p2 = n
	if p1 - p2 == 0:
		f = 0
		break
print('YNEOS'[f::2])


from sys import stdin, stdout
for _ in range(1):
	(n, srca, desa, srcb, desb) = list(map(int, stdin.readline().split()))
	a = [srca]
	b = [srcb]
	p = srca
	while 1:
		p += 1
		if p == n + 1:
			p = 1
		a += [p]
		if p == desa:
			break
	p = srcb
	while 1:
		p -= 1
		if p == 0:
			p = n
		b += [p]
		if p == desb:
			break
	f = 0
	for (aa, bb) in zip(a, b):
		if aa == bb:
			f = 1
			break
	print('YES' if f else 'NO')


(n, now1, get1, now2, get2) = map(int, input().split())
while True:
	if now1 == now2:
		print('YES')
		exit()
	if now1 == get1 or now2 == get2:
		print('NO')
		exit()
	now1 += 1
	if now1 > n:
		now1 = 1
	now2 -= 1
	if now2 == 0:
		now2 = n


(n, a, x, b, y) = input().split()
n = int(n)
a = int(a)
x = int(x)
b = int(b)
y = int(y)
met = False
count = 0
while count != n:
	if a == n:
		a = 0
	if b == 1:
		b = n + 1
	a = a + 1
	b = b - 1
	if a == b:
		met = True
	if a == x:
		break
	if b == y:
		break
	count = count + 1
if met:
	print('YES')
else:
	print('NO')


(n, pos1, x, pos2, y) = map(int, input().split())
while True:
	if pos1 + 1 > n:
		pos1 = 1
	else:
		pos1 += 1
	if pos2 == 1:
		pos2 = n
	else:
		pos2 -= 1
	if pos1 == pos2:
		print('YES')
		break
	if pos1 == x or pos2 == y:
		print('NO')
		break


(numberOfStations, danielS, danielE, vladS, vladE) = input().split()
numberOfStations = int(numberOfStations)
danielS = int(danielS)
danielE = int(danielE)
vladE = int(vladE)
vladS = int(vladS)
i = 0
meet = False
while True:
	if danielS == vladS:
		meet = True
		break
	if danielS == danielE or vladS == vladE:
		break
	if danielS == numberOfStations:
		danielS = 1
	else:
		danielS += 1
	if vladS == 1:
		vladS = numberOfStations
	else:
		vladS -= 1
print('YES' if meet else 'NO')


p = input().rstrip().split(' ')
n = int(p[0])
a = int(p[1])
x = int(p[2])
b = int(p[3])
y = int(p[4])
l = []
l.append(a)
l.append(b)
G = 0
while 1:
	if l[0] == l[1]:
		G = 1
		break
	else:
		if l[0] != x:
			if l[0] == n:
				l[0] = 1
			else:
				l[0] = l[0] + 1
		else:
			break
		if l[1] != y:
			if l[1] == 1:
				l[1] = n
			else:
				l[1] = l[1] - 1
		else:
			break
if G == 1:
	print('YES')
else:
	print('NO')


(stations, one, one_end, other, other_end) = [int(x) for x in input().split()]
one -= 1
other -= 1
one_end -= 1
other_end -= 1
travel = one
count = 0
while travel != one_end:
	count += 1
	travel = (travel + 1) % stations
one_travels = count
travel = other
count = 0
while travel != other_end:
	count += 1
	travel = (travel - 1) % stations
other_travels = count
count = 0
for i in range(min(one_travels, other_travels) + 1):
	if one == other:
		print('YES')
		exit()
	one = (one + 1) % stations
	other = (other - 1) % stations
print('NO')


(a, b, c, d, e) = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
e = int(e)
flag = 0
if b == d:
	print('YES')
else:
	while b != c and d != e:
		b += 1
		d -= 1
		if b == a + 1:
			b = 1
		if d == 0:
			d = a
		if b == d:
			flag = 1
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


(n, a, x, b, y) = map(int, input().split())
if x > a:
	r1 = [i for i in range(a, x + 1)]
else:
	r1 = [i for i in range(a, n + 1)] + [i for i in range(1, x + 1)]
if b > y:
	r2 = [i for i in range(y, b + 1)]
else:
	r2 = [i for i in range(y, n + 1)] + [i for i in range(1, b + 1)]
flag = 0
for x in range(min(len(r1), len(r2))):
	if r1[x] == r2[-1 - x]:
		flag = 1
		break
if flag == 0:
	print('NO')
else:
	print('YES')


(n, a, x, b, y) = map(int, input().split())
t_a = [a]
current = a
while current != x:
	current += 1
	if current == n + 1:
		current = 1
	t_a.append(current)
t_b = [b]
current = b
while current != y:
	current -= 1
	if current == 0:
		current = n
	t_b.append(current)
steps = min(len(t_a), len(t_b))
for i in range(steps):
	if t_a[i] == t_b[i]:
		print('YES')
		return
print('NO')


(N, a, x, b, y) = [int(i) for i in input().split(' ')]
myarr = [a]
i = a + 1
while i != x:
	if i == N + 1:
		i = 1
		continue
	myarr.append(i)
	i += 1
myarr.append(i)
arr2 = [b]
j = b - 1
while j != y:
	if j == 0:
		j = N
		continue
	arr2.append(j)
	j -= 1
arr2.append(j)
p1 = 0
p2 = 0
while p1 < len(myarr) and p2 < len(arr2):
	if myarr[p1] == arr2[p2]:
		print('YES')
		break
	p1 += 1
	p2 += 1
else:
	print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
t = 0
find = False
A = False
B = False
while not A or not B:
	if a == b and A == False and (B == False):
		find = True
		break
	if a != x:
		a += 1
		if a > n:
			a = 1
	else:
		A = True
	if b != y:
		b -= 1
		if b == 0:
			b = n
	else:
		B = True
	t += 1
print('YES' if find else 'NO')


(n, a, x, b, y) = list(map(int, input().split()))
flag = 0
lena = 0
ca = a
cb = b
while ca != x:
	ca += 1
	if ca > n:
		ca = 1
	lena += 1
lenb = 0
while cb != y:
	cb -= 1
	if cb < 1:
		cb = n
	lenb += 1
if a == b:
	flag = 1
for q in range(min(lena, lenb)):
	if a == b:
		flag = 1
		break
	a = a + 1
	if a > n:
		a = 1
	b = b - 1
	if b < 1:
		b = n
	if a == b:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


a = list(map(int, input().split()))
c = 0
c1 = a[1]
c2 = a[3]
for i in range(a[0]):
	if c1 != a[2]:
		if c1 == a[0]:
			c1 = 1
		else:
			c1 += 1
	else:
		break
	if c2 != a[4]:
		if c2 == 1:
			c2 = a[0]
		else:
			c2 -= 1
	else:
		break
	if c1 == c2:
		print('YES')
		c = 1
		break
	else:
		c = 0
if c == 0:
	print('NO')


listi = list(map(int, input().split()))
step1 = 1
step2 = 1
for i in range(listi[0]):
	if listi[1] == listi[3]:
		print('YES')
		exit()
	if listi[1] == listi[2]:
		step1 = 0
		break
	if listi[3] == listi[4]:
		step2 = 0
		break
	if listi[1] != listi[2]:
		listi[1] += step1
		if listi[1] > listi[0]:
			listi[1] %= listi[0]
	if listi[3] != listi[4]:
		listi[3] -= step2
		if listi[3] < 1:
			listi[3] = listi[0]
print('NO')


rawInput = input()
parsedInput = rawInput.split(' ')
maxStations = int(parsedInput[0])
aPos = int(parsedInput[1])
aEnd = int(parsedInput[2])
bPos = int(parsedInput[3])
bEnd = int(parsedInput[4])
while True:
	if aPos == bPos:
		print('YES')
		break
	elif aPos == aEnd or bPos == bEnd:
		print('NO')
		break
	if aPos == maxStations:
		aPos = 1
	else:
		aPos += 1
	if bPos == 1:
		bPos = maxStations
	else:
		bPos -= 1


(n, a, x, b, y) = map(int, input().split())
i = 1
while True:
	ca = (a + i - 1) % n + 1
	cb = (b - i - 1) % n + 1
	if ca == cb:
		print('YES')
		exit(0)
	if ca == x or cb == y:
		print('NO')
		exit(0)
	i += 1


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	elif p == 3:
		return list(input())
	else:
		return int(input())
(n, a, x, b, y) = f(1)
st = False
for i in range(n):
	if a == b:
		st = True
		break
	if a == x:
		break
	if b == y:
		break
	a += 1
	b -= 1
	if a == n + 1:
		a = 1
	if b == 0:
		b = n
if st:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
print('YNEOS'[all((i % n != j % n for (i, j) in zip(range(a, a + (x - a) % n + 1), range(b, b - (b - y) % n - 1, -1))))::2])


(n, a, x, b, y) = [int(x) for x in input().split()]
temp1 = a
temp2 = b
flag = False
flag1 = False
while temp1 != x and temp2 != y:
	temp1 = temp1 + 1
	if temp1 > n:
		temp1 = 1
	temp2 = temp2 - 1
	if temp2 < 1:
		temp2 = n
	if temp1 == temp2:
		flag1 = True
		break
if flag1 == True:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
l = []
if x < a:
	x = n + x
for i in range(a, x + 1):
	if i % n == 0:
		l.append(n)
	else:
		l.append(i % n)
r = []
for i in range(n * 2):
	r.append(b)
	if b == y:
		break
	b -= 1
	if b == 0:
		b = n
z = 0
for i in range(min(len(l), len(r))):
	if l[i] == r[i]:
		z = -1
		break
if z == -1:
	print('YES')
else:
	print('NO')


l = list(map(int, input().split()))
flag1 = True
flag2 = True
flag = False
while flag1 and flag2:
	if l[1] == l[2]:
		flag1 = False
	if l[3] == l[4]:
		flag2 = False
	if l[1] == l[3]:
		flag = True
	l[1] = (l[1] + 1) % l[0]
	if l[1] == 0:
		l[1] = l[0]
	l[3] = l[3] - 1
	if l[3] == 0:
		l[3] = l[0]
if flag:
	print('YES')
else:
	print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def main():
	(n, a, x, b, y) = LI()
	if a == b:
		return 'YES'
	while 1:
		a += 1
		if a > n:
			a -= n
		b -= 1
		if b < 1:
			b += n
		if a == b:
			return 'YES'
		if a == x:
			break
		if b == y:
			break
	return 'NO'
print(main())


t = 1
for test in range(t):
	(n, a, x, b, y) = map(int, input().split())
	ans = 'NO'
	for i in range(n + 2):
		a = a + 1
		if a > n:
			a = 1
		b = b - 1
		if b < 1:
			b = n
		if a == b:
			ans = 'YES'
			break
		if a == x:
			break
		if b == y:
			break
	print(ans)


(n, a, x, b, y) = list(map(int, input().split()))
k1 = a
k2 = b
f = 0
for i in range(n):
	if k1 == x or k2 == y:
		break
	if k1 < n:
		k1 += 1
	else:
		k1 = 1
	if k2 <= 1:
		k2 = n
	else:
		k2 -= 1
	if k1 == k2:
		print('YES')
		f = 1
		break
if f == 0:
	print('NO')


def move_p(x, n):
	if x + 1 > n:
		return 1
	return x + 1

def move_n(x, n):
	if x - 1 < 1:
		return n
	return x - 1

def main():
	(n, a, x, b, y) = map(int, input().split())
	ans = 'NO'
	while a != x and b != y:
		if a == b:
			ans = 'YES'
		a = move_p(a, n)
		b = move_n(b, n)
	if a == b:
		ans = 'YES'
	print(ans)
main()


(n, a, x, b, y) = map(int, input().split())
a = a - 1
x = x - 1
b = b - 1
y = y - 1
l = [i for i in range(n)]
while 1:
	if l[int(a % n)] == l[int(b % n)]:
		print('YES')
		break
	elif int(a % n) == x or int(b % n) == y:
		print('NO')
		break
	else:
		a = a + 1
		b = b - 1


(n, a, x, b, y) = map(int, input().split())
f_dis = x - a if x > a else n - (a - x)
b_dis = b - y if b > y else n - (y - b)
for _ in range(min(f_dis, b_dis)):
	if a == b:
		print('YES')
		exit()
	a += 1
	b -= 1
	if a > n:
		a = 1
	if b < 1:
		b = n
else:
	if a == b:
		print('YES')
		exit()
	print('NO')


import sys
from collections import defaultdict
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
(n, a, x, b, y) = intInp()
ans = False
while True:
	if a == b:
		ans = True
		break
	if a == x or b == y:
		break
	a += 1
	b -= 1
	if a == n + 1:
		a = 1
	if b == 0:
		b = n
if ans:
	print('YES')
else:
	print('NO')


def _1169A():
	(n, a, x, b, y) = map(int, input().split())
	while a != x and b != y:
		a += 1
		a = a % n
		if a == 0:
			a = n
		b -= 1
		b = b % n
		if b == 0:
			b = n
		if a == b:
			print('YES')
			return
	print('NO')
_1169A()


import sys
(n, a, x, b, y) = [int(_) for _ in input().split()]
while a != x and b != y:
	a += 1
	if a == n + 1:
		a = 1
	b -= 1
	if b == 0:
		b = n
	if a == b:
		print('YES')
		sys.exit()
print('NO')


import sys, math

def read_int():
	return int(sys.stdin.readline().strip())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

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

def read_string_list(delim=' '):
	return sys.stdin.readline().strip().split(delim)
(n, a, x, b, y) = read_int_list()
for i in range(n):
	if a == b:
		print('YES')
		sys.exit()
	if a == x or b == y:
		print('NO')
		sys.exit()
	a += 1
	if a == n + 1:
		a = 1
	b -= 1
	if b == 0:
		b = n
print('NO')


def circle(n, a, x, b, y):
	i = 0
	while i < n:
		if a == b:
			return 'YES'
		if (a == x or b == y) and a != b:
			return 'NO'
		if a == n:
			a = 0
		if b == 1:
			b = n + 1
		a += 1
		b -= 1
		i += 1
	return 'NO'
(n, a, x, b, y) = list(map(int, input().split()))
print(circle(n, a, x, b, y))


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
(nb_st, sta, ena, stb, enb) = RMI()
routeA = []
i = sta
while True:
	routeA.append(i)
	if i == ena:
		break
	i += 1
	if i == nb_st + 1:
		i = 1
routeB = []
i = stb
while True:
	routeB.append(i)
	if i == enb:
		break
	i -= 1
	if i == 0:
		i = nb_st
ans = 'NO'
for (x, y) in zip(routeA, routeB):
	if x == y:
		ans = 'YES'
		break
print(ans)


(n, a, x, b, y) = list(map(int, input().split()))
a_arr = [-1 for i in range(n + 1)]
b_arr = [-1 for i in range(n + 1)]
cur = a
count = 0
while cur != x:
	a_arr[cur] = count
	count += 1
	if cur == n:
		cur = 1
	else:
		cur += 1
a_arr[x] = count
cur = b
count = 0
while cur != y:
	b_arr[cur] = count
	count += 1
	if cur == 1:
		cur = n
	else:
		cur -= 1
b_arr[y] = count
ans = 'NO'
for i in range(1, n + 1):
	if a_arr[i] == b_arr[i] and a_arr[i] > 0:
		ans = 'YES'
		break
print(ans)
b


def check(l1, l2):
	l = min(len(l1), len(l2))
	for i in range(l):
		if l1[i] == l2[i]:
			return 'YES'
	return 'NO'
(n, a, x, b, y) = map(int, input().split())
if a == b:
	print('YES')
if x == y:
	print('YES')
else:
	if x >= a:
		l1 = [t1 for t1 in range(a, x + 1)]
	else:
		l1 = [t1 for t1 in range(a, n + 1)]
		for j in range(1, x + 1):
			l1.append(j)
	if y <= b:
		l2 = [t2 for t2 in range(b, y - 1, -1)]
	else:
		l2 = [t2 for t2 in range(b, 0, -1)]
		for j in range(n, y - 1, -1):
			l2.append(j)
	ans = check(l1, l2)
	print(ans)


arr = list(map(int, input().split()))
n = arr[0]
a = arr[1]
x = arr[2]
b = arr[3]
y = arr[4]
aa = a
bb = b
flag = 0
while True:
	if aa == bb:
		flag = 1
		break
	elif aa == x:
		break
	elif bb == y:
		break
	if aa == n:
		aa = 1
	else:
		aa += 1
	if bb == 1:
		bb = n
	else:
		bb -= 1
if flag == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
p1 = a
p2 = b
f = 0
if p1 == p2:
	f = 1
else:
	while p1 != x and p2 != y:
		p1 += 1
		if p1 > n:
			p1 = 1
		p2 -= 1
		if p2 < 1:
			p2 = n
		if p1 == p2:
			f = 1
			break
if f == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
f = 0
aa = []
bb = []
while a != x:
	aa.append(a)
	a += 1
	if a > n:
		a = 1
while b != y:
	bb.append(b)
	b -= 1
	if b < 1:
		b = n
aa.append(x)
bb.append(y)
h = min(len(aa), len(bb))
for i in range(0, h):
	if aa[i] == bb[i]:
		print('YES')
		f = 1
		break
if f == 0:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
t1 = [0] * n
t2 = [0] * n
a -= 1
b -= 1
x -= 1
y -= 1
cnt = 1
if x < a:
	x = x + n
for i in range(a, x + 1):
	c = i % n
	t1[c] = cnt
	cnt += 1
if y > b:
	y -= n
cnt = 1
for i in range(b, y - 1, -1):
	c2 = i % n
	t2[c2] = cnt
	cnt += 1
flag = 0
for j in range(n):
	if t1[j] == t2[j] and t1[j] != 0 and (t2[j] != 0):
		flag = 1
		print('YES')
		break
if flag == 0:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
maxRound = x - a if x > a else n - a + x
maxRound = min(b - y if b > y else n - y + b, maxRound)
ans = 'NO'
for _ in range(maxRound + 1):
	if a == b:
		ans = 'YES'
		break
	a = a + 1 if a < n else 1
	b = b - 1 if b > 1 else n
print(ans)


(n, a, x, b, y) = map(int, input().split())
flag = 0
for _ in range(n):
	if a == b:
		flag = 1
		break
	if a == x or b == y:
		break
	else:
		a += 1
		if a > n:
			a = 1
		b -= 1
		if b == 0:
			b = n
if flag == 1:
	print('YES')
else:
	print('NO')


import sys
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, a, x, b, y) = get_ints()
Arr = [i for i in range(1, n + 1)]
A = a - 1
B = b - 1
flag = 0
while A != x - 1 and B != y - 1:
	if A == B:
		flag = 1
		break
	A = (A + 1) % n
	B = (B - 1) % n
	if A == B:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
a1 = [(a + i) % n for i in range(n)]
b1 = [(b - i) % n for i in range(n)]
c = 0
for i in range(n):
	if a1[i] == 0:
		a1[i] = n
	if a1[i] == x:
		a1 = a1[:i + 1]
		break
for i in range(n):
	if b1[i] == 0:
		b1[i] = n
	if b1[i] == y:
		b1 = b1[:i + 1]
		break
for i in range(min([len(a1), len(b1)])):
	if a1[i] == b1[i]:
		print('YES')
		break
else:
	print('NO')


def main():
	(n, a, x, b, y) = list(map(int, input().split()))
	ans = False
	a -= 1
	x -= 1
	b -= 1
	y -= 1
	for i in range(n):
		a = (a + 1) % n
		b = (b - 1) % n
		if a == b:
			print('YES')
			return
		if a == x or b == y:
			print('NO')
			return
	print('NO')
main()


(n, a, x, b, y) = list(map(int, input().split()))
fl = 0
while True:
	a += 1
	if a == n + 1:
		a = 1
	b -= 1
	if b == 0:
		b = n
	if a == b:
		fl = 1
		break
	elif a == x or b == y:
		break
if fl:
	print('YES')
else:
	print('NO')


import sys
import math
import bisect

def solve(n, a, x, b, y):
	while True:
		if a == n:
			a = 1
		else:
			a += 1
		if b == 1:
			b = n
		else:
			b -= 1
		if a == b:
			break
		if a == x:
			break
		if b == y:
			break
	return a == b

def main():
	(n, a, x, b, y) = map(int, input().split())
	if solve(n, a, x, b, y):
		print('YES')
	else:
		print('NO')
main()


X = list(map(int, input().split()))
(Front, Rear) = (X[1], X[3])
while Front != X[2] and Rear != X[4]:
	Front = Front + 1 if Front + 1 != X[0] + 1 else 1
	Rear = Rear - 1 if Rear - 1 != 0 else X[0]
	if Front == Rear:
		print('YES')
		exit()
print('NO')


import sys
import os
from io import BytesIO, IOBase

def cel(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return defaultdict(int)

def ddl():
	return defaultdict(list)

def ddd():
	return defaultdict(defaultdict(int))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict
for _ in range(1):
	(n, a, x, b, y) = mi()
	f = 0
	while a != x and b != y:
		a += 1
		b -= 1
		if a > n:
			a = 1
		if b < 1:
			b = n
		if a == b:
			f = 1
			break
	if f == 0:
		print('NO')
	else:
		print('YES')


(n, a, x, b, y) = [int(i) for i in input().split()]
curra = a
currb = b
poss = 0
while a != x and b != y:
	a += 1
	b -= 1
	if a == n + 1:
		a = 1
	if b == 0:
		b = n
	if a == b:
		poss = 1
		print('YES')
		break
	if a == curra or b == currb:
		break
if poss == 0:
	print('NO')


def solution(n, a, x, b, y):
	while a != x and b != y:
		if a == b:
			return True
		a = a + 1 if a < n else 1
		b = b - 1 if b > 1 else n
	return a == b
if solution(*[int(x) for x in input().split()]):
	print('YES')
else:
	print('NO')


ent = input()
ent = ent.split()
n = int(ent[0])
a = int(ent[1])
x = int(ent[2])
b = int(ent[3])
y = int(ent[4])
encontro = 0
while 1 == 1:
	if a == b:
		encontro = 1
		break
	if a == x:
		encontro = 0
		break
	if b == y:
		encontro = 0
		break
	a += 1
	if a == n + 1:
		a = 1
	b -= 1
	if b == 0:
		b = n
if encontro == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().split())
(fir, sec) = (a, b)
while fir != x and sec != y:
	if fir == sec:
		print('YES')
		exit()
	if fir < n:
		fir += 1
	elif fir == n:
		fir = 1
	if sec > 1:
		sec -= 1
	elif sec == 1:
		sec = n
	if fir == sec:
		print('YES')
		exit()
print('NO')


(n, a, x, b, y) = map(int, input().split(' '))
(forward, backward) = ([a], [b])
f1 = a if a < x else n - a + a - 1
b1 = b if b > y else b - 1 + n - b
flag = True
for i in range(n):
	a += 1
	b -= 1
	if a == n + 1:
		a = 1
	if b == 0:
		b = n
	if a == b:
		print('YES')
		exit()
	if a == x or b == y:
		break
print('NO')


(n, a, b, x, y) = [int(_) for _ in input().split()]
a %= n
b %= n
x %= n
y %= n
while True:
	if a == x:
		print('YES')
		exit(0)
	if a == b:
		print('NO')
		exit(0)
	if x == y:
		print('NO')
		exit(0)
	a = (a + 1) % n
	x = (n + x - 1) % n


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
(n, x, a, y, b) = map(int, input().split())
x -= 1
y -= 1
a -= 1
b -= 1
while x != a and y != b:
	x += 1
	x %= n
	y -= 1
	y %= n
	if x == y:
		print('YES')
		break
else:
	print('NO')


def circularmetro(L, M):
	k = min(len(L), len(M))
	for i in range(0, k):
		if L[i] == M[i]:
			return 'YES'
	return 'NO'
L = list(map(int, input().split()))
n = L[0]
a = L[1]
x = L[2]
b = L[3]
y = L[4]
M = []
N = []
if x > a:
	for i in range(a, x + 1):
		M.append(i)
if x < a:
	for i in range(a, n + 1):
		M.append(i)
	for j in range(1, x + 1):
		M.append(j)
if y < b:
	for i in range(b, y - 1, -1):
		N.append(i)
if y > b:
	for i in range(b, 0, -1):
		N.append(i)
	for j in range(n, y - 1, -1):
		N.append(j)
print(circularmetro(M, N))


(n, a, x, b, y) = map(int, input().split())
ans = 0
curr = a
t = 205
dan = []
while curr != x:
	dan.append(curr)
	if curr + 1 > n:
		curr = 1
	else:
		curr += 1
dan.append(x)
vlad = []
curr = b
while curr != y:
	vlad.append(curr)
	if curr - 1 == 0:
		curr = n
	else:
		curr -= 1
vlad.append(y)
l = min(len(vlad), len(dan))
for i in range(l):
	if vlad[i] == dan[i]:
		ans = 1
if ans == 1:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = (int(x) for x in input().split())
f = 0
i = 0
if a <= x:
	x -= a
else:
	x += n - a
if y <= b:
	y = b - y
else:
	y = b + n - y
x = min(x, y)
while i < x:
	if a < n:
		a += 1
	else:
		a = 1
	if b > 1:
		b -= 1
	else:
		b = n
	i += 1
	if a == b:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


(q, w, e, r, t) = input().split()

def slt(n, a, x, b, y):
	if b == a:
		return 'YES'
	while b != y and a != x:
		if b == a:
			return 'YES'
		a += 1
		b -= 1
		if b < 1:
			b = n
		if a > n:
			a = 1
	if b == a:
		return 'YES'
	return 'NO'
n = int(q)
a = int(w)
x = int(e)
b = int(r)
y = int(t)
print(slt(n, a, x, b, y))


(n, a, x, b, y) = [int(x) for x in input().split()]
for i in range(0, 2 * n):
	if a == b:
		print('YES')
		exit(0)
	if a == x or b == y:
		break
	a += 1
	b -= 1
	a %= n + 1
	if b <= 0:
		b = n
	if a <= 0:
		a = 1
print('NO')


(n, a, x, b, y) = list(map(int, input().split()))
p = False
while a != x and b != y:
	if a == b:
		p = True
	a += 1
	b -= 1
	a = 1 if a == n + 1 else a
	b = n if b == 0 else b
if a == b:
	p = True
if p:
	print('YES')
else:
	print('NO')


(n, a, x, b, y) = map(int, input().strip().split())
daniel_ptr = a
vlad_ptr = b
time = 0
while daniel_ptr != x and vlad_ptr != y:
	time += 1
	if vlad_ptr == daniel_ptr:
		print('YES')
		break
	vlad_ptr = vlad_ptr - 1 or n
	daniel_ptr += 1
	if daniel_ptr > n:
		daniel_ptr = 1
else:
	if daniel_ptr == vlad_ptr:
		print('YES')
	else:
		print('NO')


(n, a, x, b, y) = map(int, input().split())
mps = []
bd = b if a < b else b + n
d = bd - a
if d % 2 == 0:
	mps.append(d // 2)
d += n
if d % 2 == 0:
	mps.append(d // 2)
if a > x:
	x += n
if b < y:
	b += n
found = False
for mp in mps:
	if a + mp <= x and b - mp >= y:
		found = True
		break
print(('NO', 'YES')[found])


t = list(map(int, input().split()))
if t[1] == t[3]:
	print('YES')
else:
	o = 0
	s1 = t[1]
	d1 = t[2]
	s2 = t[3]
	d2 = t[4]
	m = []
	n = []
	if d1 <= s1:
		d1 = d1 + t[0]
	if d2 >= s2:
		d2 = d2 - t[0]
	cost = 0
	for i in range(s1, d1 + 1, 1):
		if i % t[0] == 0:
			m.append(t[0])
		else:
			m.append(i % t[0])
	for i in range(s2, d2 - 1, -1):
		if i % t[0] == 0:
			n.append(t[0])
		else:
			n.append(i % t[0])
	o = min(len(m), len(n))
	op = 0
	for i in range(o):
		if m[i] == n[i]:
			op = 1
			print('YES')
			break
	if op == 0:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

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

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

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
(n, a, x, b, y) = nninp()
while True:
	if a == b:
		print('YES')
		exit()
	if a == x:
		break
	if b == y:
		break
	if a == n:
		a = 1
	else:
		a = a + 1
	if b == 1:
		b = n
	else:
		b = b - 1
print('NO')


import sys

def sss():
	(n, a, x, b, y) = map(int, input().split())
	a -= 1
	x -= 1
	b -= 1
	y -= 1
	while a != x and b != y:
		if a == b:
			return 'YES'
		b = (b + n - 1) % n
		a = (a + 1) % n
	if a == b:
		return 'YES'
	return 'NO'
print(sss())


(n, a, x, b, y) = map(int, input().strip().split())
(ai, bi) = (a, b)
if ai == bi:
	exit(print('YES'))
while True:
	ai = 1 if ai + 1 > n else ai + 1
	bi = n if bi - 1 < 1 else bi - 1
	if ai == bi:
		exit(print('YES'))
	if ai == x or bi == y:
		break
print('NO')


ip = list(map(int, input().split()))
n = ip[0]
a = ip[1]
x = ip[2]
b = ip[3]
y = ip[4]
flag = False
t1 = 0
if x > a:
	t1 = x - a
else:
	t1 = n - abs(x - a)
t2 = 0
if y < b:
	t2 = b - y
else:
	t2 = n - abs(b - y)
for i in range(min(t1, t2)):
	if a == n:
		a = 1
	else:
		a += 1
	if b == 1:
		b = n
	else:
		b = b - 1
	if a == b:
		flag = True
		break
if flag == True:
	print('YES')
else:
	print('NO')


a = input('')
b = a.split()
c = []
for i in range(5):
	c.insert(len(c), int(b[i]))
while not c[1] == c[2] and (not c[3] == c[4]):
	c[1] = (c[1] + c[0]) % c[0] + 1
	c[3] = c[3] - 1
	if c[3] <= 0:
		c[3] = c[0]
	if c[1] == c[3]:
		print('YES')
		break
if not c[1] == c[3]:
	print('NO')


(n, a, x, b, y) = [int(x) for x in input().split()]
ar = []
br = []
if a < x:
	ar = list(range(a, x + 1))
else:
	ar = list(range(a, n + 1)) + list(range(1, x + 1))
if b > y:
	br = list(range(b, y - 1, -1))
else:
	br = list(range(b, 0, -1)) + list(range(n, y - 1, -1))
can = False
for i in range(min(len(ar), len(br))):
	if ar[i] == br[i]:
		can = True
if can:
	print('YES')
else:
	print('NO')