using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
using System.Numerics;

class Solution
{

    static int? getVal(char c)
    {
        if (c >= 'a' && c <= 'f')
            return 10 + (c - 'a');
        if (c >= 'A' && c <= 'F')
            return 10 + (c - 'A');
        if (c >= '0' && c <= '9')
            return c - '0';
        return null;
    }

    static char? convert(char? A, char? B)
    {
        if (A == null || B == null)
            return null;
        var x = getVal(A.Value);
        var y = getVal(B.Value);
        if (x == null || y == null)
            return null;
        var res = x.Value * 16 + y.Value;
        return (char)res;
    }

    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(Console.ReadLine().Trim().Split(), int.Parse);
        var n = nm[0];
        var a = nm[1];
        var x = nm[2];
        var b = nm[3];
        var y = nm[4];
        for (int i = 0; i < n; i++)
        {
            var c1 = (a - 1 + i) % n;
            var c2 = (b - 1 - i) % n;
            c2 = c2 < 0 ? c2 + n : c2;
            if (c1 == c2 )
            {
                Console.WriteLine("YES");
                return;
            }
            if (c1 == x - 1 || c2 == y - 1)
            {
                Console.WriteLine("NO");
                return;
            }
        }
    }
}

using System;
using System.Collections.Generic;

namespace leetcode
{
    class Program
    {
        static void Main(string[] args)
        {

            //100 2 97 84 89
            //5 1 4 3 2
            bool yes = false;

            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int a = int.Parse(s[1]);
            int x = int.Parse(s[2]);

            int b = int.Parse(s[3]);
            int y = int.Parse(s[4]);

            List<int> ax = new List<int>();
            List<int> by = new List<int>();
            Queue<int> qax = new Queue<int>();
            Queue<int> qby = new Queue<int>();

            //Daniel
            if (a > x)
            {
                int c = a + 1;
                while (c <= n)
                {
                    qax.Enqueue(c++);
                }
            }
            int sa = (a > x)? 1: a + 1;
            for (int i = sa; i <= x; i++)
            {
                qax.Enqueue(i);
            }

            //vlad
            if (b < y)
            {
                int c = b - 1;
                while (c > 0)
                {
                    qby.Enqueue(c--);
                }
            }

            int sb = (b < y) ? n : b - 1;
            for (int i = sb ; i >=y; i--)
            {
                qby.Enqueue(i);
            }
            //100 2 97 84 89
            //yes
            while (qax.Count > 0 && qby.Count > 0)
            {
                int t1 = qax.Dequeue();
                int t2 = qby.Dequeue();
                if (t1 == t2)
                {
                    yes = true;
                    break;
                }
            }
            Console.WriteLine(yes == true ? "YES" : "NO");

        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Circle_Metro
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve() ? "Yes" : "No");
            writer.Flush();
        }

        private static bool Solve()
        {
            int n = Next(), a = Next(), x = Next(), b = Next(), y = Next();

            while (true)
            {
                a++;
                b--;
                if (a > n)
                    a = 1;
                if (b == 0)
                    b = n;
                if (a == b)
                    return true;
                if (a == x || b == y)
                    return false;
            }
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

/*
csc -debug A.cs && mono --debug A.exe <<< "5 1 4 3 2"
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var n = cin.NextInt();
        var a = cin.NextInt() - 1;
        var x = cin.NextInt() - 1;
        var b = cin.NextInt() - 1;
        var y = cin.NextInt() - 1;

        for (var t = 0; t <= n+5; t++) {
            if (a == b) {
                System.Console.WriteLine("YES");
                return;
            }
            if (a == x || b == y) break;
            a = (a + 1) % n;
            b = (b + n - 1) % n;
        }
        System.Console.WriteLine("NO");
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

/* Date: 27.05.2019  *  Time: 21:45 */
//
// https://docs.microsoft.com/en-us/dotnet/api/system.tuple-8?redirectedfrom=MSDN&view=netframework-4.7.2
//
//

/*
�	fflush(stdout) � ����� C++;
�	System.out.flush() � Java;
�	stdout.flush() � Python;
�	flush(output) � Pascal;

*/

using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Example
{
	public static void Main (string[] args)
	{
# if ( ! ONLINE_JUDGE )
		StreamReader sr = new StreamReader ("C:\\TRR\\2019\\Task\\07 Codeforces\\039\\A.TXT");
		StreamWriter sw = new StreamWriter ("C:\\TRR\\2019\\Task\\07 Codeforces\\039\\OUTPUT.OUT");
# endif

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

		string s;

# if ( ONLINE_JUDGE )
		s = Console.ReadLine ();
# else
		s = sr.ReadLine ();
		sw.WriteLine ("*** " + s);
# endif

		int n, a, b, x, y;
		{
			string [] ss = s.Split (' ');
			n = int.Parse (ss [0]);
			a = int.Parse (ss [1]);
			x = int.Parse (ss [2]);
			b = int.Parse (ss [3]);
			y = int.Parse (ss [4]);
		}

		bool ok = false;
		for ( int i=0; i <= n; i++ )
		{
			if ( a == b )
			{
				ok = true;
				break;
			}

			if ( a == x || b == y )
				break;

			a++; b--;
			if ( a > n )
				a = 1;
			if ( b < 1 )
				b = n;

# if ( ! ONLINE_JUDGE )
			sw.WriteLine ("*** " + a + " " + b);
# endif
		}

# if ( ONLINE_JUDGE )
		if ( ok )
			Console.WriteLine ("YES");
		else
			Console.WriteLine ("NO");
# else
		if ( ok )
			sw.WriteLine ("YES");
		else
			sw.WriteLine ("NO");
		sw.Close ();
# endif

	}
}

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
class problem
{
    static void Main()
    {
        var v = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        int n = v[0], a = v[1], x = v[2], b = v[3], y = v[4];
        int t=x>a?x-a:x+n-a;
        t=Math.Min(t,y>b?b+n-y:b-y);
        while(t-->-1)
        {
            if(a == b)
            {
                Console.WriteLine( "YES" );
                return;
            }
            else
            {
                a = a == n ? 1 : a+1;
                b = b == 1 ? n : b-1;
            }
        }
        Console.WriteLine( "NO" );

    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Codeforces
{
    class A
    {
        private static ThreadStart s_threadStart = new A().Go;

        private void Go()
        {
            int n = GetInt();
            int a = GetInt()-1;
            int x = GetInt()-1;
            int b = GetInt()-1;
            int y = GetInt()-1;

            int first = a;
            int second = b;

            while(true)
            {
                if (first == second)
                { Wl("YES"); return; }
                if (first == x)
                { Wl("NO"); return; }
                if(second == y)
                { Wl("NO"); return; }
                first = (first + 1) % n;
                second = (second + n - 1) % n;
            }
        }

        #region Template

        private static StringBuilder output = new StringBuilder();

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            output.Length = 0;
            Thread main = new Thread(new ThreadStart(s_threadStart), 200 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            Console.Write(output);
            timer.Stop();
            Console.Error.WriteLine(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            do
            {
                while (ioEnum == null || !ioEnum.MoveNext())
                {
                    ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
                }
            } while (string.IsNullOrEmpty(ioEnum.Current));

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            W(o);
            output.Append(Console.Out.NewLine);
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            W(enumerable);
            output.Append(Console.Out.NewLine);
        }

        private static void W<T>(T o)
        {
            if (o is double)
            {
                Wd((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wd((o as float?).Value, "");
            }
            else
                output.Append(o.ToString());
        }

        private static void W<T>(IEnumerable<T> enumerable)
        {
            W(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wd(double d, string format)
        {
            W(d.ToString(format, CultureInfo.InvariantCulture));
        }

        #endregion
    }
}

using System;
using System.Linq;

namespace globalLogin
{
	public class Program
	{
		public static void Main(string[] str)
		{
			int[] info = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
			Solution sol = new Solution();
			Console.WriteLine(sol.Intersect(info[0], info[1], info[2], info[3], info[4]) ? "YES" : "NO");
		}
	}

	internal class Solution
	{
		public bool Intersect(int n, int a, int x, int b, int y)
		{
			--a;
			--b;
			--x;
			--y;
			int stationA = a;
			int stationB = b;
			// bool AInTrain = false, BInTrain = false;

			for(int i = 0; i <= 2 * n; ++i,
				stationA = (stationA + 1) % n,
				stationB = ((stationB - 1) % n + n) % n)
			{
				if(stationA == stationB)
					return true;

			 	if(stationA == x || stationB == y)
				 	return false;
			}
			return false;
		}
	}
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CodeForces
{
	class Program
	{
		static void Main(string[] args)
		{
			var arr = Ints();
			var n = arr[0];
			var a = --arr[1];
			var x = --arr[2];
			var b = --arr[3];
			var y = --arr[4];

			while (true)
			{
				if (a == b)
				{
					Console.WriteLine("YES");
					return;
				}

				if (a == x || b == y)
				{
					Console.WriteLine("NO");
					return;
				}

				a = (a + 1) % n;
				b = (b - 1 + n) % n;
			}

		}

		static int Int()
		{
			return Int32.Parse(Console.ReadLine());
		}

		static (int, int) Int2()
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(), Int32.Parse);
			return (arr[0], arr[1]);
		}

		static (int, int, int) Int3()
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(), Int32.Parse);
			return (arr[0], arr[1], arr[3]);
		}

		static int[] Ints()
		{
			return Array.ConvertAll(Console.ReadLine().Split(), Int32.Parse);
		}

		static long Long()
		{
			return Int64.Parse(Console.ReadLine());
		}

		static (long, long) Long2()
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(), Int64.Parse);
			return (arr[0], arr[1]);
		}

		static (long, long, long) Long3()
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(), Int64.Parse);
			return (arr[0], arr[1], arr[2]);
		}

		static long[] Longs()
		{
			return Array.ConvertAll(Console.ReadLine().Split(), Int64.Parse);
		}

		static string Str()
		{
			return Console.ReadLine();
		}

		static void Swap<T>(ref T a, ref T b)
		{
			var t = a;
			a = b;
			b = t;
		}
	}
}

using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] rez = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int a = rez[1], b = rez[3];
            bool check = (rez[3] - rez[1] + rez[0]) % rez[0] > 0 && (rez[4] - rez[2] + rez[0]) % rez[0] < 0;
            while(a!=rez[2]&&b!=rez[4])
            {
                if (++a > rez[0]) a = 1;
                if (--b < 1) b = rez[0];
                if (a==b)
                {
                    Console.WriteLine("YES");
                    return;
                }
                if (b < a && check ) break;
            }
            Console.WriteLine("NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;

namespace Contest
{

    class Program
    {
        private int N, A, X, B, Y;
        public void Solve()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = sc.NextInt()-1;
            X = sc.NextInt()-1;
            B = sc.NextInt()-1;
            Y = sc.NextInt()-1;

            for (int i = 0; i < N; i++)
            {
                A++;
                A %= N;
                B--;
                B += N;
                B %= N;
                if (A == B)
                {
                    Console.WriteLine("YES");
                    return;

                }

                if (A == X || B == Y)
                {
                    Console.WriteLine("NO");
                    return;

                }
            }
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private char _separator;
    private StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

using System;
using System.Globalization;
using System.IO;
using System.Text;

namespace Olymp
{
  public class ProblemSolver
  {
    private readonly Tokenizer input;

    public void Solve()
    {
      var n = input.ReadInt();
      var a = input.ReadInt();
      var x = input.ReadInt();
      var b = input.ReadInt();
      var y = input.ReadInt();
      for (var i = 0; i < n && a != b && a != x && b != y; i++)
      {
        if (++a > n)
          a = 1;
        if (--b < 1)
          b = n;
      }
      Console.Write(a == b ? "YES" : "NO");
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }
  }

  #region Service classes

  public class Tokenizer
  {
    private TextReader reader;

    public string ReadToEnd()
    {
      return this.reader.ReadToEnd();
    }

    public int ReadInt()
    {
      var c = SkipWS();
      if (c == -1)
        throw new EndOfStreamException();
      var isNegative = false;
      if (c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = this.reader.Read();
        if (c == -1)
          throw new InvalidOperationException();
      }
      if (!char.IsDigit((char)c))
        throw new InvalidOperationException();
      var result = (char)c - '0';
      c = this.reader.Read();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        if (!char.IsDigit((char)c))
          throw new InvalidOperationException();
        result = result * 10 + (char)c - '0';
        c = this.reader.Read();
      }
      if (isNegative)
        result = -result;
      return result;
    }

    public string ReadLine()
    {
      return reader.ReadLine();
    }

    public long ReadLong()
    {
      return long.Parse(this.ReadToken());
    }

    public double ReadDouble()
    {
      return double.Parse(this.ReadToken(), CultureInfo.InvariantCulture);
    }

    public int[] ReadIntArray(int n)
    {
      var a = new int[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadInt();
      return a;
    }

    public long[] ReadLongArray(int n)
    {
      var a = new long[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadLong();
      return a;
    }

    public double[] ReadDoubleArray(int n)
    {
      var a = new double[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadDouble();
      return a;
    }

    public string ReadToken()
    {
      var c = SkipWS();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = this.reader.Read();
      }
      return sb.ToString();
    }

    private int SkipWS()
    {
      var c = this.reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = this.reader.Read();
      return c;
    }

    public Tokenizer(TextReader reader)
    {
      this.reader = reader;
    }
  }

  internal class Program
  {
    public static void Main(string[] args)
    {
      var solver = new ProblemSolver(Console.In);
      solver.Solve();
    }
  }

  #endregion
}

using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int A = int.Parse(str[1]);
		int X = int.Parse(str[2]);
		int B = int.Parse(str[3]);
		int Y = int.Parse(str[4]);
		string ans = "NO";
		int a1 = A;
		int b1 = B;
		for(var i=0;i<=110;i++){
			if(a1==b1){
				ans = "YES";
			}
			if(a1==X){
			    break;
			}
			if(b1==Y){
			    break;
			}
			a1 += 1;
			if(a1> N){
				a1 = 1;
			}
			b1 -= 1;
			if(b1<=0){
				b1 = N;
			}
		}
		Console.WriteLine(ans);
	}
}

using System;
using System.Linq;

namespace Codeforces
{
    public static class A
    {
        public static void Main()
        {
            var numbers = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var n = numbers[0];
            var a = numbers[1];
            var x = numbers[2];
            var b = numbers[3];
            var y = numbers[4];

            var pointA = a;
            var pointB = b;
            while (pointA != x && pointB != y)
            {
                if (pointA == pointB)
                {
                    Console.WriteLine("YES");
                    return;
                }

                if (pointA == n)
                {
                    pointA = 1;
                }
                else
                {
                    pointA++;
                }

                if (pointB == 1)
                {
                    pointB = n;
                }
                else
                {
                    pointB--;
                }
            }
            if (pointA == pointB)
            {
                Console.WriteLine("YES");
                return;
            }

            Console.WriteLine("NO");
        }
    }
}

using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] info = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            Solution sol = new Solution();
            System.Console.WriteLine(sol.Check(info) ? "YES" : "NO");
        }
    }

    internal class Solution
    {
        public bool Check(int[] info)
        {
            int n = info[0];
            int a = info[1] - 1;
            int x = info[2] - 1;
            int b = info[3] - 1;
            int y = info[4] - 1;

            int stationTrainA = 0;
            int stationTrainB = n - 1;
            bool aInTheTrain = false;
            bool bInTheTrain = false;
            for(int i = 0; i <= 2 * n ; ++i, stationTrainA = (stationTrainA + 1) % n, stationTrainB = ((stationTrainB - 1) % n + n) % n)
            {
                if(stationTrainA == a)
                    aInTheTrain = true;
                if(stationTrainB == b)
                    bInTheTrain = true;

                // System.Console.WriteLine("(" + stationTrainA + ", " + aInTheTrain + ") (" + stationTrainB + ", " + bInTheTrain + ")");
                if(aInTheTrain && bInTheTrain && stationTrainA == stationTrainB)
                    return true;

                if(stationTrainA == x && aInTheTrain)
                {
                    aInTheTrain = false;
                    break;
                }
                if(stationTrainB == y && bInTheTrain)
                {
                    bInTheTrain = false;
                    break;
                }
            }
            return false;
        }
    }
}

using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] info = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            Solution sol = new Solution();
            System.Console.WriteLine(sol.Check(info) ? "YES" : "NO");
        }
    }

    internal class Solution
    {
        public bool Check(int[] info)
        {
            int n = info[0];
            int a = info[1] - 1;
            int x = info[2] - 1;
            int b = info[3] - 1;
            int y = info[4] - 1;

            int stationTrainA = 0;
            int stationTrainB = n - 1;
            bool aInTheTrain = false;
            bool bInTheTrain = false;
            for(int i = 0; i <= n ; ++i, stationTrainA = (stationTrainA + 1) % n, stationTrainB = ((stationTrainB - 1) % n + n) % n)
            {
                if(stationTrainA == a)
                    aInTheTrain = true;
                if(stationTrainB == b)
                    bInTheTrain = true;

                // System.Console.WriteLine("(" + stationTrainA + ", " + aInTheTrain + ") (" + stationTrainB + ", " + bInTheTrain + ")");
                if(aInTheTrain && bInTheTrain && stationTrainA == stationTrainB)
                    return true;

                if(stationTrainA == x)
                    aInTheTrain = false;
                if(stationTrainB == y)
                    bInTheTrain = false;
            }
            return false;
        }
    }
}

using System;
using System.Linq;

namespace globalLogin
{
	public class Program
	{
		public static void Main(string[] str)
		{
			int[] info = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
			Solution sol = new Solution();
			Console.WriteLine(sol.Intersect(info[0], info[1], info[2], info[3], info[4]) ? "YES" : "NO");
		}
	}

	internal class Solution
	{
		public bool Intersect(int n, int a, int x, int b, int y)
		{
			int stationA = 0;
			int stationB = n - 1;
			--x;
			--y;
			bool AInTrain = false, BInTrain = false;

			for(int i = 0; i <= 2 * n; ++i,
				stationA = ++stationA % n,
				stationB = ((stationB - 1) % n + n) %n)
			{
				if(stationA == a)
					AInTrain = true;
				if(stationB == b)
					BInTrain = true;

				if(stationA == stationB && BInTrain == AInTrain && AInTrain == true)
					return true;

				if(stationA == x || stationB == y)
					return false;
			}
			return false;
		}
	}
}

using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] info = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            Solution sol = new Solution();
            System.Console.WriteLine(sol.Check(info) ? "YES" : "NO");
        }
    }

    internal class Solution
    {
        public bool Check(int[] info)
        {
            int n = info[0];
            int a = info[1] - 1;
            int x = info[2] - 1;
            int b = info[3] - 1;
            int y = info[4] - 1;

            int stationTrainA = 0;
            int stationTrainB = n - 1;
            bool aInTheTrain = false;
            bool bInTheTrain = false;
            for(int i = 0; i <= n ; ++i, stationTrainA = (stationTrainA + 1) % n, stationTrainB = ((stationTrainB - 1) % n + n) % n)
            {
                if(stationTrainA == a)
                    aInTheTrain = true;
                if(stationTrainB == b)
                    bInTheTrain = true;

                // System.Console.WriteLine("(" + stationTrainA + ", " + aInTheTrain + ") (" + stationTrainB + ", " + bInTheTrain + ")");
                if(aInTheTrain && bInTheTrain && stationTrainA == stationTrainB)
                    return true;

                if(stationTrainA == x)
                {
                    aInTheTrain = false;
                    break;
                }
                if(stationTrainB == y)
                {
                    bInTheTrain = false;
                    break;
                }
            }
            return false;
        }
    }
}

using System;
using System.Linq;
namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] rez = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int a = rez[1], b = rez[3];
            while(a!=rez[2]||b!=rez[4])
            {
                a++;
                b--;
                if (a > rez[0]) a = 1;
                if (b < 1) b = rez[0];
                if (a==b)
                {
                    Console.WriteLine("YES");
                    return;
                }
                if (b < a) break;
            }
            Console.WriteLine("NO");
        }
    }
}

using System;
namespace leetcode
{
    class Program
    {
        static void Main(string[] args)
        {

            bool yes = false;

            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int a = int.Parse(s[1]);
            int x = int.Parse(s[2]);
            int b = int.Parse(s[3]);
            int y = int.Parse(s[4]);

            if (a == b)
            {
                Console.WriteLine("YES");
            }
            else if( x == y &&  (x - a) == (y - b))
            {
                Console.WriteLine("YES");
            }
            else
            {
                while (a <= x && b >= y)
                {
                    a++;
                    b--;
                    if (a == b)
                    {
                        yes = true;
                        break;
                    }
                }

                Console.WriteLine(yes == true ? "YES" : "NO");
            }
        }
    }
}

using System;
using System.Collections.Generic;

namespace leetcode
{
    class Program
    {
        static void Main(string[] args)
        {

            bool yes = false;

            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int a = int.Parse(s[1]);
            int x = int.Parse(s[2]);

            int b = int.Parse(s[3]);
            int y = int.Parse(s[4]);

            if (a <= x && b >= y )
            {
                while (a <= x && b >= y)
                {
                    a++;
                    b--;
                    if (a == b)
                    {
                        yes = true;
                        break;
                    }
                }

            }
            else
            {

                List<int> ax = new List<int>();
                List<int> by = new List<int>();
                int i = a + 1;
                for (; i <= n; i++)
                {
                    ax.Add(i);
                }
                i = 1;
                while (i <=x )
                {
                    ax.Add(i);
                    i++;
                }

                for ( int k = b -1; k >= 1; k--)
                {
                    by.Add(k);
                }
                i = n;
                while (i >= y)
                {
                    by.Add(i);
                    i--;
                }
                for (i = 0; i < ax.Count && i < by.Count; i++)
                {
                    if(ax[i] == by[i])
                    {
                        yes = true;
                        break;
                    }
                }

            }

            Console.WriteLine(yes == true ? "YES" : "NO");

        }
    }
}

using System;
using System.Collections.Generic;

namespace leetcode
{
    class Program
    {
        static void Main(string[] args)
        {

            bool yes = false;

            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int a = int.Parse(s[1]);
            int x = int.Parse(s[2]);

            int b = int.Parse(s[3]);
            int y = int.Parse(s[4]);

            /*if (a <= x && b >= y )
            {
                while (a <= x && b >= y)
                {
                    a++;
                    b--;
                    if (a == b)
                    {
                        yes = true;
                        break;
                    }
                }

            }
            else
            {*/
            int p = n;
            int h = n;
            if (a <= x && b >= y)
            {
                n = x;
                p = 0;
                h = 101;

            }
            List<int> ax = new List<int>();
            List<int> by = new List<int>();
            int i = a + 1;
            for (; i <= n; i++)
            {
                ax.Add(i);
            }
            while (h <= x)
            {
                ax.Add(i);
                i++;
            }

            for (int k = b - 1; k >= 1; k--)
            {
                by.Add(k);
            }

            while (p >= y)
            {
                by.Add(p);
                p--;
            }
            for (i = 0; i < ax.Count && i < by.Count; i++)
            {
                if (ax[i] == by[i])
                {
                    yes = true;
                    break;
                }
            }

            //}

            Console.WriteLine(yes == true ? "YES" : "NO");

        }
    }
}

using System;
using System.Collections.Generic;

namespace leetcode
{
    class Program
    {
        static void Main(string[] args)
        {

            //100 2 97 84 89
            //5 1 4 3 2
            bool yes = false;

            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int a = int.Parse(s[1]);
            int x = int.Parse(s[2]);

            int b = int.Parse(s[3]);
            int y = int.Parse(s[4]);

            List<int> ax = new List<int>();
            List<int> by = new List<int>();
            Queue<int> qax = new Queue<int>();
            Queue<int> qby = new Queue<int>();

            //Daniel
            if (a > x)
            {
                int c = a + 1;
                while (c <= n)
                {
                    qax.Enqueue(c++);
                }
            }
            int sa = (a > x)? 1: a + 1;
            for (int i = sa; i <= x; i++)
            {
                qax.Enqueue(i);
            }

            //vlad
            if (b < y)
            {
                int c = b - 1;
                while (c > 0)
                {
                    qby.Enqueue(c--);
                }
            }

            int sb = (b < y) ? n : b;
            for (int i = sb; i >=y; i--)
            {
                qby.Enqueue(i);
            }
            //100 2 97 84 89
            //yes
            while (qax.Count > 0 && qby.Count > 0)
            {
                int t1 = qax.Dequeue();
                int t2 = qby.Dequeue();
                if (t1 == t2)
                {
                    yes = true;
                    break;
                }
            }
            Console.WriteLine(yes == true ? "YES" : "NO");

        }
    }
}

/*
csc -debug A.cs && mono --debug A.exe <<< "5 1 4 3 2"
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var n = cin.NextInt();
        var a = cin.NextInt() - 1;
        var x = cin.NextInt() - 1;
        var b = cin.NextInt() - 1;
        var y = cin.NextInt() - 1;

        for (var t = 0; t <= n+5; t++) {
            if (a == b) {
                System.Console.WriteLine("YES");
                return;
            }
            if (a == x || b == y) break;
            a = (a + 1) % n;
            b = (b - 1) % n;
        }
        System.Console.WriteLine("NO");
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

/* Date: 27.05.2019  *  Time: 21:45 */
//
// https://docs.microsoft.com/en-us/dotnet/api/system.tuple-8?redirectedfrom=MSDN&view=netframework-4.7.2
//
//

/*
�	fflush(stdout) � ����� C++;
�	System.out.flush() � Java;
�	stdout.flush() � Python;
�	flush(output) � Pascal;

*/

using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Example
{
	public static void Main (string[] args)
	{
# if ( ! ONLINE_JUDGE )
		StreamReader sr = new StreamReader ("C:\\TRR\\2019\\Task\\07 Codeforces\\039\\A.TXT");
		StreamWriter sw = new StreamWriter ("C:\\TRR\\2019\\Task\\07 Codeforces\\039\\OUTPUT.OUT");
# endif

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

		string s;

# if ( ONLINE_JUDGE )
		s = Console.ReadLine ();
# else
		s = sr.ReadLine ();
		sw.WriteLine ("*** " + s);
# endif

		int n, a, b, x, y;
		{
			string [] ss = s.Split (' ');
			n = int.Parse (ss [0]);
			a = int.Parse (ss [1]);
			x = int.Parse (ss [2]);
			b = int.Parse (ss [3]);
			y = int.Parse (ss [4]);
		}

		bool ok = false;
		for ( int i=0; i <= n; i++ )
		{
			if ( a == b )
			{
				ok = true;
				break;
			}
			a++; b--;
			if ( a > n )
				a = 1;
			if ( b < 1 )
				b = n;

# if ( ! ONLINE_JUDGE )
			sw.WriteLine ("*** " + a + " " + b);
# endif

			if ( a == x || b == y )
				break;
		}

# if ( ONLINE_JUDGE )
		if ( ok )
			Console.WriteLine ("YES");
		else
			Console.WriteLine ("NO");
# else
		if ( ok )
			sw.WriteLine ("YES");
		else
			sw.WriteLine ("NO");
		sw.Close ();
# endif

	}
}

/* Date: 27.05.2019  *  Time: 21:45 */
//
// https://docs.microsoft.com/en-us/dotnet/api/system.tuple-8?redirectedfrom=MSDN&view=netframework-4.7.2
//
//

/*
�	fflush(stdout) � ����� C++;
�	System.out.flush() � Java;
�	stdout.flush() � Python;
�	flush(output) � Pascal;

*/

using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Example
{
	public static void Main (string[] args)
	{
# if ( ! ONLINE_JUDGE )
		StreamReader sr = new StreamReader ("C:\\TRR\\2019\\Task\\07 Codeforces\\039\\A.TXT");
		StreamWriter sw = new StreamWriter ("C:\\TRR\\2019\\Task\\07 Codeforces\\039\\OUTPUT.OUT");
# endif

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

		string s;

# if ( ONLINE_JUDGE )
		s = Console.ReadLine ();
# else
		s = sr.ReadLine ();
		sw.WriteLine ("*** " + s);
# endif

		int n, a, b, x, y;
		{
			string [] ss = s.Split (' ');
			n = int.Parse (ss [0]);
			a = int.Parse (ss [1]);
			x = int.Parse (ss [2]);
			b = int.Parse (ss [3]);
			y = int.Parse (ss [4]);
		}

		bool ok = false;
		for ( int i=0; i <= n; i++ )
		{
			if ( a == b )
			{
				ok = true;
				break;
			}
			a++; b--;
			if ( a > n )
				a = 1;
			if ( b < 1 )
				b = n;
		}

# if ( ONLINE_JUDGE )
		if ( ok )
			Console.WriteLine ("YES");
		else
			Console.WriteLine ("NO");
# else
		if ( ok )
			sw.WriteLine ("YES");
		else
			sw.WriteLine ("NO");
		sw.Close ();
# endif

	}
}

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
class problem
{
    static void Main()
    {
        var v = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        int n = v[0], a = v[1], x = v[2], b = v[3], y = v[4];
        int t = n;
        while(t-->0)
        {
            if(a == b)
            {
                Console.WriteLine( "YES" );
                break;
            }
            else
            {
                a = a == n ? 1 : a++;
                b = b == 1 ? n : b--;
            }
        }
        Console.WriteLine( "NO" );

    }
}

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
class problem
{
    static void Main()
    {
        var v = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        int n = v[0], a = v[1], x = v[2], b = v[3], y = v[4];
        int t = n;
        while(t-->-1)
        {
            if(a == b)
            {
                Console.WriteLine( "YES" );
                return;
            }
            else
            {
                a = a == n ? 1 : a+1;
                b = b == 1 ? n : b-1;
            }
        }
        Console.WriteLine( "NO" );

    }
}

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
class problem
{
    static void Main()
    {
        var v = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        int n = v[0], a = v[1], x = v[2], b = v[3], y = v[4];
        int t=x>a?x-a:x+n-a;
        t=Math.Min(t,y>b?y-b:y+n-b);
        while(t-->=-1)
        {
            if(a == b)
            {
                Console.WriteLine( "YES" );
                return;
            }
            else
            {
                a = a == n ? 1 : a+1;
                b = b == 1 ? n : b-1;
            }
        }
        Console.WriteLine( "NO" );

    }
}

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
class problem
{
    static void Main()
    {
        var v = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        int n = v[0], a = v[1], x = v[2], b = v[3], y = v[4];
        int t=x>a?x-a:x+n-a;
        t=Math.Min(t,y>b?y-b:y+n-b);
        while(t-->=0)
        {
            if(a == b)
            {
                Console.WriteLine( "YES" );
                return;
            }
            else
            {
                a = a == n ? 1 : a+1;
                b = b == 1 ? n : b-1;
            }
        }
        Console.WriteLine( "NO" );

    }
}

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
class problem
{
    static void Main()
    {
        var v = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        int n = v[0], a = v[1], x = v[2], b = v[3], y = v[4];
        int t = n;
        while(t-->0)
        {
            if(a == b)
            {
                Console.WriteLine( "YES" );
                return;
            }
            else
            {
                a = a == n ? 1 : a+1;
                b = b == 1 ? n : b-1;
            }
        }
        Console.WriteLine( "NO" );

    }
}

using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
using System.Numerics;

class Solution
{

    static int? getVal(char c)
    {
        if (c >= 'a' && c <= 'f')
            return 10 + (c - 'a');
        if (c >= 'A' && c <= 'F')
            return 10 + (c - 'A');
        if (c >= '0' && c <= '9')
            return c - '0';
        return null;
    }

    static char? convert(char? A, char? B)
    {
        if (A == null || B == null)
            return null;
        var x = getVal(A.Value);
        var y = getVal(B.Value);
        if (x == null || y == null)
            return null;
        var res = x.Value * 16 + y.Value;
        return (char)res;
    }

    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(Console.ReadLine().Trim().Split(), int.Parse);
        var n = nm[0];
        var a = nm[1];
        var x = nm[2];
        var b = nm[3];
        var y = nm[4];
        for (int i = 0; i < n; i++)
        {
            var c1 = (a + i) % (n+1);
            var c2 = (b - i) % (n+1);
            c2 = c2 < 0 ? c2 + (n+1) : c2;
            if (c1 == c2 )
            {
                Console.WriteLine("YES");
                return;
            }
            if (c1 == x || c2 == y)
            {
                Console.WriteLine("NO");
                return;
            }
        }
    }
}

using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
using System.Numerics;

class Solution
{

    static int? getVal(char c)
    {
        if (c >= 'a' && c <= 'f')
            return 10 + (c - 'a');
        if (c >= 'A' && c <= 'F')
            return 10 + (c - 'A');
        if (c >= '0' && c <= '9')
            return c - '0';
        return null;
    }

    static char? convert(char? A, char? B)
    {
        if (A == null || B == null)
            return null;
        var x = getVal(A.Value);
        var y = getVal(B.Value);
        if (x == null || y == null)
            return null;
        var res = x.Value * 16 + y.Value;
        return (char)res;
    }

    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(Console.ReadLine().Trim().Split(), int.Parse);
        var n = nm[0];
        var a = nm[1];
        var x = nm[2];
        var b = nm[3];
        var y = nm[4];
        for (int i = 0; i < n; i++)
        {
            var c1 = (a + i) % n;
            var c2 = (b - i) % n;
            c2 = c2 < 0 ? c2 + n : c2;
            if (c1 == c2 )
            {
                Console.WriteLine("YES");
                return;
            }
            if (c1 == x || c2 == y)
            {
                Console.WriteLine("NO");
                return;
            }
        }
    }
}