const
        nmax = 105;
var
        n,i,pos1,pos2 : integer;
        a : array[1..nmax] of integer;
BEGIN
        //assign(input,'input.inp');reset(input);
        //assign(output,'output.out');rewrite(output);
        readln(n);
        for i:=1 to n do read(a[i]);
        pos1:= 1;
        while (pos1 < n) and (a[pos1 + 1] > a[pos1]) do
                inc(pos1);
        pos2:= n;
        while (pos2 > 0) and (a[pos2 - 1] > a[pos2]) do
                dec(pos2);
        for i:=pos1 + 1 to pos2 do
                if a[i] <> a[i-1] then
                        begin
                                write('NO');
                                halt;
                        end;
        write('YES');
END.

var n,i:longint;
    x,y,z:boolean;
    a:array[1..100] of longint;

procedure xuat;
   begin
   write('NO');
   halt;
   end;

procedure xuli3(i:longint);
   var j:longint;
   begin
   for j:=i to n-1 do
      IF a[j+1]>=a[j] then xuat;
   write('YES');
   halt;
   end;

procedure xuli2(i:longint);
   var j:longint;
   begin
   for j:=i to n-1 do
      IF (a[j+1]>a[j]) then xuat
      else
         IF (a[j+1]<a[j]) and (z=true) then
            begin
            xuli3(j);
            z:=false;
            end
         else
            IF z=false then xuat;
   write('YES');
   halt;
   end;

procedure xuli1(i:longint);
   var j:longint;
   begin
   for j:=i to n-1 do
      IF (a[j+1]<a[j]) and (x=true) then
         begin
         xuli3(j);
         x:=false;
         end
      else
         IF x=false then xuat
         else
            IF (a[j+1]=a[j]) and (y=true) then
               begin
               xuli2(j);
               y:=false;
               end
            else
               IF x=false then xuat;
   write('YES');
   halt;
   end;

begin
readln(n);
x:=true;
y:=true;
z:=true;
for i:=1 to n do read(a[i]);
xuli1(1);
end.

Var a:array[1..100] of longint;
n,i,k,j,f:longint;
begin
readln(n);
for i:=1 to n do
read(a[i]);
if a[1]<a[2] then k:=1;
if a[1]=a[2] then k:=2;
if a[1]>a[2] then k:=4;
if n=1 then k:=0;
                  i:=3;
if k=1 then for i:=3 to n do begin
                 if a[i]=a[i-1] then begin
                                       k:=2;
                                       f:=i;
                                       break;
                                     end;
                if a[i]<a[i-1] then begin
                                      k:=4;
                                      f:=i;
                                      break;
                                    end;
                                    end;
if f=0 then f:=3;
if k=2 then for j:=f to n do begin
                      if (a[j]>a[j-1]) then begin
                                              write('NO');
                                              k:=3;
                                              break;
                                            end;
                      if (a[j]<a[j-1]) then begin
                                              k:=4;
                                              f:=j;
                                              break;
                                            end;
                                            end;
if f=0 then f:=3;
if k=4 then for i:=f to n do
                       if (a[i]>=a[i-1]) then begin
                                                 write('NO');
                                                 k:=3;
                                                 break;
                                               end;
                                               if k<>3 then write('YES');
                                               end.

var
n,u,i,o:longint;
a:array[1..101]of longint;
begin
readln(n);
for i:=1 to n do
read(a[i]);
i:=2; if n=1 then begin
write('YES'); halt; end;
if a[n]=a[n-1] then a[n+1]:=a[n];
if a[n]<a[n-1] then a[n]:=a[n]-1;
while (a[i-1]<a[i]) and (i<n+1) do inc(i);
while (a[i-1]=a[i]) and (i<n+1) do inc(i);
while (a[i]<a[i-1]) and (i<n+1) do inc(i);
if i<n+1 then write('NO') else
write('YES'); end.

var n,i,l,m,k,z,q,j:integer;
a: array [1..1000] of integer;
begin
        readln (n);
        for i:=1 to n do
        read(a[i]);
        for j:=1 to n-1 do
        if a[j]<>a[j+1] then q:=q+1;
        if q=0 then writeln ('Yes')else
        begin
                l:=1;
                while (a[l]<>a[l+1]) and (a[l]<a[l+1]) do
                l:=l+1;
                m:=l;
                z:=l;
                k:=0;
                        while (k=0) and (m<>1) do
                        begin
                                if a[m]>a[m-1]then
                                m:=m-1 else
                                k:=1;
                        end;
                        if k<>0 then writeln('NO') else
                        begin
                                while a[z]=a[z+1] do
                                z:=z+1;

                                while (z<>n) and (k=0) do
                                begin
                                        if a[z]>a[z+1]
                                        then z:=z+1 else k:=1;
                                end;
                                if k<>0 then writeln('NO') else
                                writeln('Yes');
                          end;
          end;
end.

var
   n,i,flag:longint;
   a:array[1..1000] of longint;
begin
   readln (n);
   for i:=1 to n do read(a[i]);
   flag:=1;
   i:=1;
   while (i<n)and(a[i]<a[i+1]) do
      inc(i);
   while (i<n)and(a[i]=a[i+1]) do
   begin
      inc(i);
      flag:=2;
   end;
   while (i<n) and(a[i]>a[i+1]) do
      inc(i);
   if (i=n)     then writeln ('YES') else writeln ('NO');
end.

var n,i,tang,giam,hue:longint;
    a:array [1..1000] of longint;
begin
 readln(n);
 for i:=1 to n do
   read(a[i]);
 tang:=0; hue:=0; giam:=0;
 i:=2;
 while (a[i]>a[i-1]) and (i<=n) do
  begin
   tang:=i;
   inc(i);
  end;
  while (a[i]=a[i-1]) and (i<=n) do
   begin
    hue:=i;
    inc(i);
   end;
  if hue=0 then begin hue:=tang; dec(tang); end;
  while (a[i]<a[i-1]) and (i<=n) do
   begin
    giam:=i;
    i:=i+1;
   end;
  if i<=n then begin writeln('No'); halt; end;
   if (tang=0) or (giam=0) then writeln('Yes')
   else if (tang<hue) and (hue<giam) then writeln('Yes')
   else writeln('No');
end.

var i,n: integer;
    incr, cons, decr, ok: boolean;
    arr: array [1..1000] of integer;
begin
    readln (n);
    incr := false; decr := false; cons := false; ok := true;
    for i:=1 to n do read(arr[i]);
    for i:=2 to n do begin
        if (not incr) and (arr[i-1] >= arr[i]) then incr := true;
        if (not incr) and (arr[i-1] > arr[i]) then ok := false;
        if (incr) and (not cons) and (arr[i-1] > arr[i]) then cons := true;
        if (incr) and (not cons) and (arr[i-1] < arr[i]) then ok := false;
        if (incr) and (cons) and (arr[i-1] <= arr[i]) then ok := false;
    end;
    if (ok) then write ('YES') else write ('NO');
    //readln (n);
end.

const
  maxn = 100;
var
  check: boolean;
  n, i: shortint;
  a: array [1..maxn] of integer;

begin
  {assign(input,  'a.inp');
  reset(input);
  assign(output, 'a.out');
  rewrite(output);}

  readln(n);
  for i := 1 to n do read(a[i]);
  i := 1;
  while (a[i] < a[i+1]) and (i < n) do inc(i);
  while (a[i] = a[i+1]) and (i < n) do inc(i);
  while (a[i] > a[i+1]) and (i < n) do inc(i);
  if i = n then writeln('YES') else writeln('NO');

  {close(input);
  close(output);}
end.

var     a:array[0..200] of integer;
        i,j,z,max,vt1,vt2,n:integer;
begin
        readln(n);
        for i:=1 to n do read(a[i]);

        max:=a[1];  vt1:=1;
        for i:=2 to n do if a[i]>max then begin max:=a[i]; vt1:=i; end;
        for i:= vt1 to n do if a[i]=max then vt2:=i;
        i:=vt2;
        while (i<n) and (a[i+1]<a[i]) do inc(i);
        j:=vt1;
        while (j>1) and (a[j-1]<a[j]) do dec(j);
        z:=vt1;
        while (z<n) and (a[z+1]=a[z]) do inc(z);
        if (i=n) and  (j=1) and (z=vt2) then writeln('yes') else writeln('no');
end.

var
n,k,i:integer;
a:array[1..101] of integer;
begin
readln(n);
for i:=1 to n do
    read(a[i]);
k:=0;

for i:=1 to n-1 do begin
    if a[i]<a[i+1] then a[i]:=1
    else
        if a[i]=a[i+1] then a[i]:=2
        else
            if a[i]>a[i+1] then a[i]:=3;
end;

 for i:=1 to n-2 do begin
    if a[i]>a[i+1] then begin
        write('NO');
        exit;
    end;
 end;

write('YES');
end.

type mas = array[1..100] of integer;
var n,i:byte;
	a:mas;
BEGIN
	read(n);
	for i:=1 to n do
		read(a[i]);

	i:=1;
	while (a[i]<a[i+1]) and (i<n) do
	begin
		inc(i);
	end;

	if i=n then
	begin
		writeln('YES');
		exit;
	end;
	if a[i]<a[i+1] then
	begin
		writeln('NO');
		exit;
	end;

	inc(i);

	while (a[i]=a[i-1]) and (i<n) do
	begin
		inc(i);

	end;

	if i=n+1 then
	begin
		writeln('YES');
		exit;
	end;

	if a[i]>a[i-1] then
	begin
		writeln('NO');
		exit;
	end;

	inc(i);
	while (a[i]<a[i-1]) and (i<n) do
	begin
		inc(i);
	end;

	if a[i]>=a[i-1] then
	begin
		writeln('NO');
		exit;
	end;
	writeln('YES');
END.

var
n,i:longint;
a:array[-10..10000]of longint;
bol:boolean;
begin
readln(n);
for i:=1 to n do read(a[i]);
for i:=1 to n-1 do begin
    if a[i]<a[i+1] then a[i]:=1
    else
    if a[i]=a[i+1] then a[i]:=2
    else
    if a[i]>a[i+1] then a[i]:=3;
end;
for i:=1 to n-2 do if a[i]>a[i+1] then bol:=true;
if bol then writeln('NO')
else
writeln('YES');
end.

var n:longint;
    i:longint;
    x,y:longint;
    a:array[0..110]of longint;
begin
  read(n);
  //x:=false;
  for i:=1 to n do
  read(a[i]);
  for i:=1 to n do
  if a[i]>a[i-1] then x:=i;
  for i:=1 to n do
  if a[i]>a[i+1] then
  begin
    y:=i;
    break;
  end;
  if x>y then
  begin
    writeln('NO');
    exit;
  end else
  begin
    for i:=1 to x-1 do
    if a[i]>=a[i+1] then
    begin
      writeln('NO');
      exit;
    end;
    for i:=y+1 to n do
    if a[i]>=a[i-1] then
    begin
      writeln('NO');
      exit;
    end;
    writeln('YES');
  end;
end.

const   fi='';
var
        a:array[1..100] of int32;
        n:int32;

procedure solve;
var i,l,r:int32; ok:boolean;
begin
        assign(input,fi); reset(input);
        readln(n);
        for i:=1 to n do read(a[i]);
        ok:= true;
        l:= 1;
        while (l<n) and (a[l]<a[l+1]) do inc(l);
        r:= n;
        while (r>1) and (a[r]<a[r-1]) do dec(r);
        if r>l then
        begin
                if a[l]>a[l+1] then ok:= false;
                if a[r]>a[r-1] then ok:= false;
        end;
        if r-l>0 then
        for i:= l to r-1 do if a[i]<>a[i+1] then ok:= false;
        if ok then write('YES') else write('NO');
end;
begin
        solve;
end.

var a:array[0..101]of longint;
       n,i,max,l,r,f:longint;
begin
	readln(n);
	for i:=1 to n do read(a[i]);
	if n=1 then begin
		writeln('YES');
		exit;
	end;
	if n=2 then begin
	writeln('YES');
	exit;
	end;
    max:=a[1];
    for i:=2 to n do if a[i]>max then max:=a[i];
    l:=0;
    for i:=1 to n do if a[i]=max then begin
    	l:=i;
    	break;
    end;
    r:=n+1;
    for i:=n downto 1 do if a[i]=max then begin
    	r:=i;
    	break;
    end;
    f:=0;
    a[0]:=a[1]-1;
    if l<>r then for i:=l to r-1 do if a[i]<>a[i+1]then f:=1;
    for i:=0 to l-1 do if a[i]>=a[i+1] then begin
    	f:=1;
    	break;
    end;
    a[n+1]:=a[n]-1;
    for i:=n+1 downto r+1 do if a[i]>=a[i-1]then f:=1;
    if f=1 then writeln('NO')
    else writeln('YES');
end.

var n,i:longint;A:array[0..100] of longint;
procedure       mo;
begin
        assign(input,'test.inp');reset(input);
        assign(output,'test.out');rewrite(output);
end;
procedure       dong;
begin
        close(input);close(output);
end;
procedure       nhap;
begin
        readln(n);
        if (n=1) then
                begin
                writeln('YES');
                halt;
                end;
        for i:=1 to n do
                read(A[i]);
end;
procedure       xuli;
var kt:longint;
begin
        kt:=1;
        if A[1]>A[2] then kt:=3;
        if A[1]<A[2] then kt:=1
        else if A[1]=A[2] then kt:=2;
        for i:=3 to n do
                begin
                if (kt=2) and (A[i]>A[i-1]) then
                        begin
                        writeln('NO');
                        halt;
                        end
                else if (kt=2) and (A[i]<A[i-1]) then kt:=3
                else if (kt=1) and (A[i]=A[i-1]) then kt:=2
                else if (kt=1) and (A[i]<A[i-1]) then kt:=3

                else if (kt=3) and (A[i]=A[i-1]) then
                        begin
                        writeln('NO');
                        halt;
                        end
                else if (kt=3) and (A[i]>A[i-1]) then
                        begin
                        writeln('NO');
                        halt;
                        end;
                end;
        writeln('YES');
end;
begin
   //     mo;
        nhap;
        xuli;
     //   dong;
end.

{$mode objfpc}

var
  n:integer;
  o,last,i :integer;
  kind:integer;

procedure axx;
  begin
    write('NO'); halt;
  end;

begin
  read(n);
  for i:=1 to n do
    begin
      read(o);
      if kind = 0 then
        begin
          if last = o then kind:=1;
          if last > o then kind:=2;
        end
      else
      if kind = 1 then
        begin
          if last < o then axx;
          if last > o then kind:=2;
        end
      else
      if kind = 2 then
        begin
          if last < o then axx;
          if last = o then axx;
        end;
      last:=o;
    end;
  write('YES');
end.

   const nn=1600000; nnn=200000;eps=0.0000000001;
   label 1,2;
    type    real=extended;  {string=ansistring;}
    int64=longint;
    mas=array [0..nn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of int64;mass1=^mass;
    var qq,p3,start,modul,pp,ot,q,ll,rr,aa,bb,cc,p1,p2,l,r,pos,t,kolx,kolo,nm,n,k,s1,s2,m,s,imax,smin,cen,dl,t2,i1,p,besk:int64;
    tt,ii,jj,step, i,j:longint;
     time:real;
     pole:array[-10..200,-10..200] of char;
     ssot,sssnew:array[-10..3000000] of char;
     smas:array[-10..2000000]of string;
     skobk,zz,z,sum,c,d,x,y,a,b:array[-1000002..6000000] of int64;
     per,dda,ddb:array[-10..120,-10..120] of int64;
     ss3,ss1,ss2:string;
    ss:string;ch:char;
    maxpr:array[0..nn] of string;
    st2:array[0..nnn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     xx,yy:array[-1..nn] of double;
     yot:double;
     prost:array [-1000..6000000] of boolean;
       flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

  function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;
  tt:zap; tt1:zap1;
begin
  if a<b then begin r:=a;a:=b;b:=r; end;
  x2:=1;x1:=0;y2:=0;y1:=1;
  while b>0 do
    begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;
          a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;

    end;
    d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;
   evkl:=tt1;
end;

function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

function good(ii,jj:longint):boolean;
var i,j:longint; flag:boolean;
begin
   flag:=true;
   for i:=2 to ii do if a[i]<=a[i-1] then flag:=false;
   for i:=jj+1 to n do if a[i]>=a[i-1] then flag:=false;
   for i:=ii+1 to jj do if a[i]<>a[i-1] then flag:=false;

   good:=flag;
end;

begin
  {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }
     read(n); for i:=1 to n do read(a[i]);
     for ii:=1 to n do for jj:=ii to n do
    begin
     if good(ii,jj) then flag:=true;
   {  writeln(ii,' ',jj,' ',good(ii,jj));
  }  end;
     if flag then write('YES') else write('NO');

   1:          close(output);
end.

var
n,k,i:integer;
a:array[1..101] of integer;
begin
readln(n);
for i:=1 to n do
read(a[i]);
k:=0;

for i:=1 to n-1 do begin
if a[i]<a[i+1] then a[i]:=1 else
if a[i]=a[i+1] then a[i]:=2 else
if a[i]>a[i+1] then a[i]:=3;
end;

 for i:=1 to n-2 do begin
 if a[i]>a[i+1] then begin write('NO');exit;end;
 end;

write('YES');
end.

var
	n, i, k, s: byte;
	a: array[1..100] of integer;
begin
	readln(n);
	for i:=1 to n do read(a[i]);
	k:=1;
	for i:=1 to n do
		if a[i+1] > a[i] then
			k:=i + 1
		else
			break;
	s:=n;
	for i:=n downto 1 do
		if a[i - 1] > a[i] then
			s:=i - 1
		else
			break;
	for i:=k to s - 1 do
		if a[i] <> a[i + 1] then
			begin
				write('NO');
				exit;
			end;
	writeln('YES');
end.

const
fin='unimodal.inp';
fon='unimodal.out';
var
a:array[1..100] of longint;
i,j,n:longint;
t,b,g,kt:boolean;
begin
{assign(input,fin);reset(input);
assign(output,fon);rewrite(output);}
readln(n);t:=true;
b:=false;
g:=false;kt:=true;
for i:=1 to n do read(a[i]);
for i:=2 to n do
   begin
   if t=true then
      begin
      {if a[i]<a[i-1] then
         begin
         kt:=false;
         break;
         end;  }
      if a[i]<=a[i-1] then
         begin
         t:=false;
         b:=true;
         g:=false;
         end;
      end;
   if b=true then
      begin
      if a[i]>a[i-1] then
         begin
         kt:=false;
         break;
         end;
      if a[i]<a[i-1] then
         begin
         b:=false;
         g:=true;
         t:=false;
         end;
      end;
   if g=true then
      begin
      if a[i]>=a[i-1] then
         begin
         kt:=false;
         break;
         end;
      end;
   end;
if kt=true then write('YES')
else write('NO');
{close(input);close(output);}
end.

var n,i,m:longint;
    a:array [1..1000] of longint;
begin
   readln(n);
   for i:=1 to n do read(a[i]);
   m:=0;
   for i:=1 to n do
   begin
      if m=0 then
      begin
         if a[i]>a[i+1] then m:=2;
         if a[i]=a[i+1] then m:=1;
      end;
      if m=1 then
      begin
         if a[i]<a[i+1] then
         begin
            writeln('NO');
            exit;
         end
         else
            if a[i]>a[i+1] then m:=2;
      end;
      if m=2 then
      begin
         if a[i]<=a[i+1] then
         begin
            writeln('NO');
            exit;
         end;
      end;
   end;
   writeln('YES');
end.

var	i,j,n:longint;
	a:array[0..105] of longint;

begin
	readln(n);
	fillchar(a,sizeof(a),0);
	for i:=1 to n do
		read(a[i]);
	i:=2;
	if a[i]>a[i-1] then
	begin
		while (i<=n) and (a[i]>a[i-1]) do inc(i);
	end;
	if a[i]=a[i-1] then
	begin
		while (i<=n) and (a[i]=a[i-1]) do inc(i);
	end;
	if a[i]<a[i-1] then
	begin
		while (i<=n) and (a[i]<a[i-1]) do inc(i);
	end;
	if i>n then writeln('YES') else writeln('NO');
end.

const   fi='test.inp';
        fo='test.out';
var     a:array[0..1000] of longint;
        n:longint;
        kq:string;
procedure Nhap;
var     i:longint;
begin
        //assign(input,fi);
        //reset(input);
        readln(n);
        for i:=1 to n do
                read(a[i]);
        //close(input);
end;

procedure Main;
var     i:longint;
begin
        kq:='NO';             i:=1;           a[0]:=-1;

        while a[i-1]<a[i] do inc(i);
        while a[i-1]=a[i] do inc(i);
        while a[i-1]>a[i] do inc(i);

        if i>=n+1 then kq:='YES';
end;
procedure Xuat;
begin
        //assign(output,fo);
        //rewrite(output);
        write(kq);
        //close(output);
end;
begin
        Nhap;
        main;
        Xuat;
end.

const fi='';
      fo='';
var a:array[1..101] of integer;
    n:integer;

procedure docf;
var f:text; i:integer;
begin
  assign(f,fi); reset(f);
  readln(f,n);
  for i:=1 to n do
   read(f,a[i]);
  close(f);
end;

procedure solve;
var f:Text; i:integer;
begin
  assign(f,fo); rewrite(f);
  i:=2;
  while (i<=n) and (a[i-1]<a[i]) do inc(i);
  while (i<=n) and (a[i-1]=a[i]) do inc(i);
  while (i<=n) and (a[i-1]>a[i]) do inc(i);
  if (i<=n) then writeln(f,'NO') else writeln(f,'YES');
  close(f);
end;

begin
  docf;
  solve;
end.

const
    fi='';
    fo='';
    maxn=100;
var n:longint;
    a:array[1..maxn]of longint;
procedure input;
var f:text;
    i:longint;
begin
    assign(f,fi);
    reset(f);
    readln(f,n);
    for i:=1 to n do read(f,a[i]);
    close(f);
end;
function ans:boolean;
var base,i:longint;
begin
    base:=-1;
    for i:=2 to n do
    begin
        if(base=1)and(a[i]>=a[i-1])then exit(false);
        if(base=0)then
        begin
            if(a[i]>a[i-1])then exit(false);
            if(a[i]<a[i-1])then base:=1;
        end;
        if(base=-1)then
        begin
            if(a[i]<a[i-1])then base:=1;
            if(a[i]=a[i-1])then base:=0;
        end;
    end;
    exit(true);
end;
procedure output;
var f:text;
begin
    assign(f,fo);
    rewrite(f);
    if(ans)then write(f,'YES') else write(f,'NO');
    close(f);
end;
begin
    input;
    output;
end.

var n,i,tang,giam,hue:longint;
    a:array [1..1000] of longint;
begin
 readln(n);
 for i:=1 to n do
   read(a[i]);
 tang:=0; hue:=0; giam:=0;
 i:=2;
 while (a[i]>a[i-1]) and (i<=n) do
  begin
   tang:=i;
   inc(i);
  end;
  while (a[i]=a[i-1]) and (i<=n) do
   begin
    hue:=i;
    inc(i);
   end;
  if hue=0 then begin hue:=tang; dec(tang); end;
  while (a[i]<a[i-1]) and (i<=n) do
   begin
    giam:=i;
    inc(i);
   end;
  if i<=n then begin writeln('No'); halt; end;
   if (tang=0) or (giam=0) then writeln('Yes')
   else if (tang<hue) and (hue<giam) then writeln('Yes')
   else writeln('No');
end.

var
  n,k,i:integer;
  a:array[1..101] of integer;
begin
  readln(n);
  for i:=1 to n do read(a[i]);
  for i:=1 to n-1 do
   begin
    if a[i]<a[i+1] then a[i]:=1 else
    if a[i]=a[i+1] then a[i]:=2 else
    if a[i]>a[i+1] then a[i]:=3;
   end;
 for i:=1 to n-2 do
  if a[i]>a[i+1] then begin write('NO');exit;end;
 write('YES');
end.

const fi='';
    fo='';
var f:Text;
    a:array[1..101] of integer;
    n:byte;
procedure NHap;
var i:byte;
begin
    assign(f,fi);reset(F);
    read(f,n);
    for i:=1 to n do read(f,a[i]);
    close(F);
end;

procedure process;
var  i:byte;
begin
    assign(f,fo);rewrite(F);
    i:=1;
    while a[i]<a[i+1] do inc(i);
    while a[i]=a[i+1] do inc(i);
    while a[i]>a[i+1] do inc(i);
    if (i=n+1) then writeln(f,'YES') else writeln(f,'NO');
    close(F);
end;

begin
    NHap;
    process;
end.

var x,n,i,l:longint;
var r11,r21,r31,r32:boolean;
begin
  read(n);l:=0;
  for i:=1 to n do
  begin
    read(x);
    //if r1 and (x>l) then begin writeln('NO');exit;end;
    //if r2 and ((x=l) or (xthen begin writeln('NO');exit;end;
    //if not r1 and (x<l) then begin writeln('NO');exit;end;
    //if x<l then r2:=true;
    if (x>l) and not r11 then r11:=true
    else if (x>l) and r21 then begin writeln('NO');exit;end;
    if (x=l) and r11 and not r21 then begin r21:=true;end
    else if (x=l) and r31 then begin writeln('NO');exit;end;
    if (x<l) and not r31 then begin r21:=true;r31:=true;end;
    l:=x;
  end;
  writeln('YES');
end.

var
  n,now,i:longint;
  a:array[0..1000]of longint;
begin
  read(n);
  read(a[1]);
  now:=1;
  for i:=2 to n do
    begin
      read(a[i]);
      if a[i]<a[i-1] then now:=3
      else if a[i]=a[i-1] then
        begin
          if now=3 then
            begin
              write('NO');
              halt;
            end
          else now:=2;
        end
      else begin
             if now>1 then
             begin
               write('NO');
               halt;
             end
           end;
    end;
  write('YES');
end.

Uses math;
Var i,n,maxv,d,c,d1,d2:longint;
    kt:string;
    a:array[0..100+10] of longint;

BEGIN
        Read(n);
        For i:=1 to n do
                BEGIN
                 Read(a[i]);
                 maxv:=max(maxv,a[i]);
                END;
        //kt:='YES';
        For i:=1 to n do
         If a[i]=maxv then begin d:=i; break; end;
        For i:=n downto 1 do
         If a[i]=maxv then
                BEGIN
                 c:=i; break;
                END;
        For i:=d to c-1 do
         If a[i]<>a[i+1] then begin writeln('NO'); halt; end;
        d1:=1; d2:=1;
        For i:=2 to d do
         If a[i]>a[i-1] then inc(d1);
        For i:=n-1 downto c do
         If a[i]>a[i+1] then inc(d2);
        If (d1+d2+c-d-1=n) then writeln('YES') else writeln('NO');
END.

program yan;
  var ar:array[1..1000]of integer;
      i,j,x,y,a,b,n,m:longint;
begin
  readln(n);
  for i:=1 to n do
    read(ar[i]);
  for i:=1 to n-1 do
    begin
      if (ar[i]<ar[i+1])and(y=0)and(b=0) then continue
      else
      if (ar[i]=ar[i+1])and(y=0) then b:=1
      else
      if (ar[i]>ar[i+1]) then y:=1
      else begin write('NO'); exit; end;
    end;
  write('YES');
end.

const
  fi='';
  fo='';
var
  a:array[1..100] of longint;
  k,i,j,n:longint;
  ans:string;

begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);
  readln(n);
  for i:=1 to n do read(a[i]);
  ans:='YES';
  i:=1;
  j:=n;
  while (i<n) and (a[i]<a[i+1]) do inc(i);
  while (j>1) and (a[j]<a[j-1]) do dec(j);
  for k:=i to j do
    if a[k]<>a[i] then
      begin
        ans:='NO';
        break;
      end;
  write(ans);
  close(input);
  close(output);
end.

var
  k,i,a,t,t1,t2,t3,errors:integer;
begin
  readln(k);
  read(t);
  for i:=2 to k do
    begin
      read(a);
      if (t<a)and(t2=0)and(t3=0)
        then
          inc(t1)
        else
          if (t=a)and(t3=0)
            then
              inc(t2)
            else
              if (a<t)
                then
                  inc(t3)
                else
                  inc(errors);
      t:=a;
    end;
  if (errors > 0)
    then
      writeln('NO')
    else
      writeln('YES');
end.

var
        a:array[1..100]of integer;
        n,i,step,b:integer;
begin
readln(n);
for i:=1 to n do
        read(a[i]);
i:=2;
b:=a[1];
while (a[i]>b) and (i<=n) do
        begin
        b:=a[i];
        inc(i);
        end;
while (a[i]=b) and (i<=n) do
        begin
        b:=a[i];
        inc(i);
        end;
while (a[i]<b) and (i<=n) do
        begin
        b:=a[i];
        inc(i);
        end;
if i=n+1 then writeln('YES') else writeln('NO');
end.

const
        nmax = 105;
var
        n,i,pos1,pos2 : integer;
        a : array[1..nmax] of integer;
BEGIN
        //assign(input,'input.inp');reset(input);
        //assign(output,'output.out');rewrite(output);
        readln(n);
        for i:=1 to n do read(a[i]);
        pos1:= 1;
        while (pos1 < n) and (a[pos1 + 1] > a[pos1]) do
                inc(pos1);
        pos2:= n;
        while (pos2 > 0) and (a[pos2 - 1] > a[pos2]) do
                dec(pos2);
        for i:=pos1 + 1 to pos2 - 1 do
                if a[i] <> a[i+1] then
                        begin
                                write('NO');
                                halt;
                        end;
        write('YES');
END.

const
        nmax = 105;
var
        n,i,vt : integer;
        a : array[1..nmax] of integer;
BEGIN
        //assign(input,'input.inp');reset(input);
        //assign(output,'output.out');rewrite(output);
        readln(n);
        for i:=1 to n do read(a[i]);
        vt:= 0;
        for i:=1 to n-1 do
                if a[i+1] <= a[i] then
                        begin
                                vt:= i;
                                break;
                        end;
        if vt = n then
                begin
                        write('YES');
                        halt;
                end;
        for i:=vt + 1 to n-1 do
                if a[i+1] <> a[i] then
                        begin
                                vt:= i;
                                break;
                        end;
        if vt = n then
                begin
                        write('YES');
                        halt;
                end;
        while (vt < n) do
                begin
                        if a[vt + 1] > a[vt] then
                                begin
                                        write('NO');
                                        halt;
                                end;
                        inc(vt);
                end;
        write('YES');
END.

const
        nmax = 105;
var
        n,i,vt : integer;
        a : array[1..nmax] of integer;
BEGIN
        //assign(input,'input.inp');reset(input);
        //assign(output,'output.out');rewrite(output);
        readln(n);
        for i:=1 to n do read(a[i]);
        inc(n);
        a[n]:= 0;
        vt:= 0;
        for i:=1 to n-1 do
                if a[i+1] <= a[i] then
                        begin
                                vt:= i;
                                break;
                        end;
        if vt = n then
                begin
                        write('YES');
                        halt;
                end;
        for i:=vt + 1 to n-1 do
                if a[i+1] <> a[i] then
                        begin
                                vt:= i;
                                break;
                        end;
        if vt = n then
                begin
                        write('YES');
                        halt;
                end;
        while (vt < n) do
                begin
                        if a[vt + 1] >= a[vt] then
                                begin
                                        write('NO');
                                        halt;
                                end;
                        inc(vt);
                end;
        write('YES');
END.

const
        nmax = 105;
var
        n,i,vt : integer;
        a : array[1..nmax] of integer;
BEGIN
        //assign(input,'input.inp');reset(input);
        //assign(output,'output.out');rewrite(output);
        a[1]:= 0;
        readln(n);
        for i:=1 to n do readln(a[i+1]);
        a[n+2]:= 0;
        n:= n + 2;
        vt:= 0;
        for i:=1 to n-1 do
                if a[i+1] <= a[i] then
                        begin
                                vt:= i;
                                break;
                        end;
        if vt = n then
                begin
                        write('YES');
                        halt;
                end;
        for i:=vt + 1 to n-1 do
                if a[i+1] <> a[i] then
                        begin
                                vt:= i;
                                break;
                        end;
        if vt = n then
                begin
                        write('YES');
                        halt;
                end;
        while (vt < n) do
                begin
                        if a[vt + 1] >= a[vt] then
                                begin
                                        write('NO');
                                        halt;
                                end;
                        inc(vt);
                end;
        write('YES');
END.

const
        nmax = 105;
var
        n,i,vt : integer;
        a : array[1..nmax] of integer;
BEGIN
        //assign(input,'input.inp');reset(input);
        //assign(output,'output.out');rewrite(output);
        a[1]:= 0;
        readln(n);
        for i:=1 to n do read(a[i+1]);
        a[n+2]:= 0;
        n:= n + 2;
        vt:= 0;
        for i:=1 to n-1 do
                if a[i+1] <= a[i] then
                        begin
                                vt:= i;
                                break;
                        end;
        if vt = n then
                begin
                        write('YES');
                        halt;
                end;
        for i:=vt + 1 to n-1 do
                if a[i+1] <> a[i] then
                        begin
                                vt:= i;
                                break;
                        end;
        if vt = n then
                begin
                        write('YES');
                        halt;
                end;
        while (vt < n) do
                begin
                        if a[vt + 1] >= a[vt] then
                                begin
                                        write('NO');
                                        halt;
                                end;
                        inc(vt);
                end;
        write('YES');
END.

const
    fi='';
    fo='';
    maxn=100;
var n:longint;
    a:array[1..maxn]of longint;
procedure input;
var f:text;
    i:longint;
begin
    assign(f,fi);
    reset(f);
    readln(f,n);
    for i:=1 to n do read(f,a[i]);
    close(f);
end;
function ans:boolean;
var base,i:longint;
begin
    base:=-1;
    for i:=2 to n do
    begin
        if(base=1)and(a[i]>=a[i-1])then exit(false);
        if(base=0)then
        begin
            if(a[i]>a[i-1])then exit(false);
            if(a[i]<a[i-1])then base:=1;
        end;
        if(base=-1)then
        begin
            if(a[i]<a[i-1])then exit(false);
            if(a[i]=a[i-1])then base:=0;
        end;
    end;
    exit(true);
end;
procedure output;
var f:text;
begin
    assign(f,fo);
    rewrite(f);
    if(ans)then write(f,'YES') else write(f,'NO');
    close(f);
end;
begin
    input;
    output;
end.

var
 i,j,n,l,kol
 : longint;
 a : array[1..100] of longint;
 pr,sf : array[0..101] of boolean;
begin
 readln(n);
 for i:=1 to n do read(a[i]);
 pr[1]:=true;
 for i:=2 to n do if a[i]>a[i-1] then pr[i]:=true else  break;
 sf[n]:=true;
 for i:=n-1 downto 1 do if a[i]>a[i+1] then sf[i]:=true else break;
 i:=2;
 while (i<=n) do
  begin
   l:=i;
   j:=i+1;
   while (a[j]=a[i]) do inc(j); dec(j);
   i:=j;
   if (pr[l]) and (sf[i]) then begin writeln('YES'); halt; end;
   inc(i);
  end;
 kol:=0;
 for i:=2 to n do if a[i]<>a[i-1] then inc(kol);
 if kol=0 then writeln('YES') else
 writeln('NO');
end.

var
  n,i,now,j,t:longint;
  a:array[0..1000]of longint;
  bo,boo:boolean;
begin
  read(n);
  read(a[1]);
  bo:=false;
  boo:=false;
  for i:=2to n do
    begin
      read(a[i]);
      if a[i]<a[i-1] then
        begin
          if now=0 then now:=1;
          if now=2 then
             begin
               if bo then begin
               write('NO');
               halt;
               end
               else begin
                      bo:=true;
                      now:=1;
                    end;
             end;
        end
      else if a[i]>a[i-1] then
        begin
          if now=0 then now:=2;
          if now=1 then
             begin
               if bo then begin
               write('NO');
               halt;
               end
               else begin
                      bo:=true;
                      now:=2;
                    end;
             end
        end
      else begin
             if bo then begin
               write('NO');
               halt;
               end;
             if t=0 then t:=a[i]
             else if t<>a[i] then
               begin
                    write('NO');
                    halt;
                  end;
           end;
    end;
  write('YES');
end.

Uses math;
Var i,n,maxv,vt:longint;
    kt:string;
    a:array[0..100+10] of longint;

BEGIN
        Read(n);
        For i:=1 to n do read(a[i]);
        vt:=1; maxv:=a[1]; kt:='YES';
        For i:=2 to n do
         If a[i]>=maxv then
                BEGIN
                 vt:=i;
                 maxv:=a[i];
                END;
        For i:=2 to vt do
         If a[i]<a[i-1] then kt:='NO';
        For i:=vt+1 to n do
         If a[i]>a[i-1] then kt:='NO';
        Writeln(kt);
END.

const
  fi='';
  fo='';
var
  a:array[1..100] of longint;
  k,i,j,n:longint;
  ans:string;

begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);
  readln(n);
  for i:=1 to n do read(a[i]);
  ans:='YES';
  i:=1;
  j:=n;
  while (i<n) and (a[i]<a[i+1]) do inc(i);
  while (j>1) and (a[j-1]>a[j]) do dec(j);
  writeln(i);
  writeln(j);
  //if a[i]>a[i+1] then ans:='NO';
  //if a[j]>a[j-1] then ans:='NO';
  for k:=i to j do
    if a[k]<>a[i] then
      begin
        ans:='NO';
        break;
      end;
  write(ans);
  close(input);
  close(output);
end.

var n,i:longint;
    x,y,z:boolean;
    a:array[1..100] of longint;

procedure xuat;
   begin
   write('NO');
   halt;
   end;

procedure xuli3(i:longint);
   var j:longint;
   begin
   for j:=i to n-1 do
      IF a[j+1]>=a[j] then xuat;
   write('YES');
   halt;
   end;

procedure xuli2(i:longint);
   var j:longint;
   begin
   for j:=i to n-1 do
      IF (a[j+1]>a[j]) then xuat
      else
         IF (a[j+1]<a[j]) and (z=true) then
            begin
            xuli3(j);
            z:=false;
            end
         else
            IF z=false then xuat;
   write('YES');
   halt;
   end;

procedure xuli1(i:longint);
   var j:longint;
   begin
   for j:=i to n-1 do
      IF (a[j+1]<a[j]) and (x=true) then
         begin
         xuli3(j);
         x:=false;
         end
      else
         IF x=false then xuat
         else
            IF (a[j+1]=a[j]) and (y=true) then
               begin
               xuli2(j);
               y:=false;
               end
            else
               IF x=false then xuat;
   end;

begin
readln(n);
x:=true;
y:=true;
z:=true;
for i:=1 to n do read(a[i]);
xuli1(1);
end.

var n,i,l,m,k,z,q,j:integer;
a: array [1..1000] of integer;
begin
        readln (n);
        for i:=1 to n do
        read(a[i]);
        for j:=1 to n-1 do
        if a[j]<>a[j+1] then q:=q+1;
        if q=0 then writeln ('Yes')else
        begin
                l:=1;
                while (a[l]<>a[l+1]) and (a[l]<a[l+1])  do
                l:=l+1;
                m:=l;
                z:=l;
                k:=0;
                        while (k=0) and (m<>1) do
                        begin
                                if a[m]>a[m-1]then
                                m:=m-1 else
                                k:=1;
                        end;
                        if k<>0 then writeln('NO') else
                        begin
                                while (z<>n) and (k=0) do
                                begin
                                        if (a[z]>=a[z+1]) and (a[z]<=a[l])
                                        then z:=z+1 else k:=1;
                                end;
                                if k<>0 then writeln('NO') else
                                writeln('Yes');
                          end;
          end;
end.

var n,i,l,m,k,z,q,j:integer;
a: array [1..1000] of integer;
begin
        readln (n);
        for i:=1 to n do
        read(a[i]);
        for j:=1 to n-1 do
        if a[j]<>a[j+1] then q:=q+1;
        if q=0 then writeln ('Yes')else
        begin
                l:=1;
                while a[l]<>a[l+1] do
                l:=l+1;
                m:=l;
                z:=l;
                k:=0;
                        while (k=0) and (m<>1) do
                        begin
                                if a[m]>a[m-1]then
                                m:=m-1 else
                                k:=1;
                        end;
                        if k<>0 then writeln('NO') else
                        begin
                                while (z<>n) and (k=0) do
                                begin
                                        if (a[z]>=a[z+1]) and (a[z]<=a[l])
                                        then z:=z+1 else k:=1;
                                end;
                                if k<>0 then writeln('NO') else
                                writeln('Yes');
                          end;
          end;
end.

type mas = array[1..100] of integer;
var n,i:byte;
	a:mas;
BEGIN
	read(n);
	for i:=1 to n do
		read(a[i]);

	i:=1;
	while (a[i]<a[i+1]) and (i<n) do
	begin
		inc(i);
	end;

	if i=n then
	begin
		writeln('YES');
		exit;
	end;
	if a[i]<a[i+1] then
	begin
		writeln('NO');
		exit;
	end;

	inc(i);

	while (a[i]=a[i-1]) and (i<n) do
	begin
		inc(i);

	end;

	if i=n then
	begin
		writeln('YES');
		exit;
	end;

	if a[i]>a[i-1] then
	begin
		writeln('NO');
		exit;
	end;

	inc(i);
	while (a[i]<a[i-1]) and (i<n) do
	begin
		inc(i);
	end;

	if a[i]>=a[i-1] then
	begin
		writeln('NO');
		exit;
	end;
	writeln('YES');
END.

type mas = array[1..100] of integer;
var n,i:byte;
	a:mas;
BEGIN
	read(n);
	for i:=1 to n do
		read(a[i]);

	i:=1;
	while (a[i]<a[i+1]) and (i<n) do
	begin
		inc(i);
	end;

	if a[i]<a[i+1] then
	begin
		writeln('NO');
		exit;
	end;

	inc(i);

	while (a[i]=a[i-1]) and (i<n) do
	begin
		inc(i);

	end;

	if i<n then inc(i);

	if a[i]>a[i-1] then
	begin
		writeln('NO');
		exit;
	end;

	inc(i);
	while (a[i]<a[i-1]) and (i<n) do
	begin
		inc(i);
	end;

	if a[i]>=a[i-1] then
	begin
		writeln('NO');
		exit;
	end;
	writeln('YES');
END.

type mas = array[1..100] of integer;
var n,i:byte;
	a:mas;
BEGIN
	read(n);
	for i:=1 to n do
		read(a[i]);

	if n=1 then
	begin
		writeln('YES');
		exit;
	end;

	i:=1;
	while (a[i]<a[i+1]) and (i<n) do
	begin
		inc(i);
	end;

	if a[i]<a[i+1] then
	begin
		writeln('NO');
		exit;
	end;

	inc(i);

	while (a[i]=a[i-1]) and (i<n) do
	begin
		inc(i);

	end;

	if i<n then inc(i);

	if a[i]>a[i-1] then
	begin
		writeln('NO');
		exit;
	end;

	inc(i);
	while (a[i]<a[i-1]) and (i<n) do
	begin
		inc(i);
	end;

	if a[i]>=a[i-1] then
	begin
		writeln('NO');
		exit;
	end;
	writeln('YES');
END.

var
n,i,ind:longint;
a:array[-1000..100000]of longint;
bol:boolean;
begin
readln(n);
for i:=1 to n do begin
    read(a[i]);
end;
for i:=2 to n do begin
    if a[i]<=a[i-1] then begin
        ind:=i-1;
        break;
    end;
end;

for i:=2 to ind do begin
    if a[i]<=a[i-1] then bol:=true;
end;
i:=ind;
while  i<=n-1 do begin
    if a[i]=a[i+1] then begin

    inc(i);
    ind:=i;
    end
    else begin
        ind:=i;
        inc(i);
        break;
    end;
end;          {
for i:=ind to n-1 do begin
    if a[i]<>a[i+1] then begin
        ind:=i;
        break;
    end;
end;           }
for i:=ind+1 to n do begin
    if a[i]>=a[i-1] then bol:=true;
end;
if bol then writeln('NO')
else
writeln('YES');
end.

var
bol,bol1:boolean;
n,i,ind:longint;
a:array[-100..1000]of longint;
begin
readln(N);

for i:=1 to n do read(A[i]);
if n=1 then writeln('YES')
else begin
for i:=2 to n do begin
    if a[i]<a[i-1] then ind:=i-1;
    if a[i]=a[i-1] then begin
        ind:=i-1;
        break;
    end;
end;
for i:=ind to n-1 do begin
    if a[i]<a[i+1] then bol:=true;
    if a[i]>a[i+1] then begin
        bol1:=true;

        ind:=i;
        break;
    end;
end;
//writeln(ind);
if bol1 then begin
    for i:=ind to n-1 do begin
        if a[i]<=a[i+1] then bol:=true;
    end;
end;
if bol then writeln('NO')
else
writeln('YES');
end;
end.

var n:longint;
    i:longint;
    x,y:longint;
    a:array[0..110]of longint;
begin
  read(n);
  //x:=false;
  for i:=1 to n do
  read(a[i]);
  for i:=1 to n do
  if a[i]>a[i-1] then x:=i;
  for i:=1 to n do
  if a[i]>a[i+1] then
  begin
    y:=i;
    break;
  end;
  if x>y then
  begin
    writeln('NO');
    exit;
  end else
  begin
    for i:=y+1 to n do
    if a[i]>=a[i-1] then
    begin
      writeln('NO');
      exit;
    end;
    writeln('YES');
  end;
end.

const   fi='';
var
        a:array[1..100] of int32;
        n:int32;

procedure solve;
var i,l,r:int32; ok:boolean;
begin
        //assign(input,fi); reset(input);
        readln(n);
        for i:=1 to n do read(a[i]);
        ok:= true;
        l:= 1;
        while (l<n) and (a[l]<a[l+1]) do inc(l);
        if a[l]>a[l+1] then ok:= false;
        r:= n;
        while (r>1) and (a[r]<a[r-1]) do dec(r);
        if a[r]>a[r-1] then ok:= false;
        if r-l>0 then
        for i:= l to r-1 do if a[i]<>a[i+1] then ok:= false;
        if ok then write('YES') else write('NO');
end;
begin
        solve;
end.

var n,i:longint;A:array[0..104] of longint;
procedure       mo;
begin
        assign(input,'test.inp');reset(input);
        assign(output,'test.out');rewrite(output);
end;
procedure       dong;
begin
        close(input);close(output);
end;
procedure       nhap;
begin
        readln(n);
        if (n=1) then
                begin
                writeln('YES');
                halt;
                end;
        for i:=1 to n do
                read(A[i]);
end;
procedure       xuli;
var kt:longint;
begin
        kt:=1;
        if A[1]>A[2] then
                begin
                writeln('NO');
                halt;
                end;
        if A[1]<A[2] then kt:=1
        else if A[1]=A[2] then kt:=2;
        for i:=3 to n do
                begin
                if (kt=2) and (A[i]>A[i-1]) then
                        begin
                        writeln('NO');
                        halt;
                        end
                else if (kt=2) and (A[i]<A[i-1]) then kt:=3
                else if (kt=1) and (A[i]=A[i-1]) then kt:=2
                else if (kt=1) and (A[i]<A[i-1]) then kt:=3

                else if (kt=3) and (A[i]=A[i-1]) then
                        begin
                        writeln('NO');
                        halt;
                        end
                else if (kt=3) and (A[i]>A[i-1]) then
                        begin
                        writeln('NO');
                        halt;
                        end;
                end;
        writeln('YES');
end;
begin
       // mo;
        nhap;
        xuli;
        //dong;
end.

var n,i:longint;A:array[0..100] of longint;
procedure       mo;
begin
        assign(input,'test.inp');reset(input);
        assign(output,'test.out');rewrite(output);
end;
procedure       dong;
begin
        close(input);close(output);
end;
procedure       nhap;
begin
        readln(n);
        if (n=1) then
                begin
                writeln('YES');
                halt;
                end;
        for i:=1 to n do
                read(A[i]);
end;
procedure       xuli;
var kt:longint;
begin
        kt:=1;
        if A[1]>A[2] then
                begin
                writeln('NO');
                halt;
                end;
        if A[1]<A[2] then kt:=1
        else if A[1]=A[2] then kt:=2;
        for i:=3 to n do
                begin
                if (kt=2) and (A[i]>A[i-1]) then
                        begin
                        writeln('NO');
                        halt;
                        end
                else if (kt=2) and (A[i]<A[i-1]) then kt:=3
                else if (kt=1) and (A[i]=A[i-1]) then kt:=2
                else if (kt=1) and (A[i]<A[i-1]) then kt:=3

                else if (kt=3) and (A[i]=A[i-1]) then
                        begin
                        writeln('NO');
                        halt;
                        end
                else if (kt=3) and (A[i]>A[i-1]) then
                        begin
                        writeln('NO');
                        halt;
                        end;
                end;
        writeln('YES');
end;
begin
       // mo;
        nhap;
        xuli;
        //dong;
end.

var
n,k,i:integer;
a:array[1..101] of integer;
begin
readln(n);
for i:=1 to n do
read(a[i]);
k:=0;

for i:=1 to n-1 do begin
if a[i]<a[i+1] then a[i]:=1;
if a[i]=a[i+1] then a[i]:=2;
if a[i]>a[i+1] then a[i]:=3;
end;

 for i:=1 to n-2 do begin
 if a[i]>a[i+1] then begin write('NO');exit;end;
 end;

write('YES');
end.

var n,i,m:longint;
    a:array [1..1000] of longint;
begin
   readln(n);
   for i:=1 to n do read(a[i]);
   m:=0;
   for i:=1 to n do
   begin
      if m=0 then
      begin
         if a[i]>a[i+1] then
         begin
            writeln('NO');
            exit;
         end
         else
            if a[i]=a[i+1] then m:=1;
      end;
      if m=1 then
      begin
         if a[i]<a[i+1] then
         begin
            writeln('NO');
            exit;
         end
         else
            if a[i]>a[i+1] then m:=2;
      end;
      if m=2 then
      begin
         if a[i]<=a[i+1] then
         begin
            writeln('NO');
            exit;
         end;
      end;
   end;
   writeln('YES');
end.

   const nn=1600000; nnn=200000;eps=0.0000000001;
   label 1,2;
    type    real=extended;  {string=ansistring;}
    int64=longint;
    mas=array [0..nn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of int64;mass1=^mass;
    var qq,p3,start,modul,pp,ot,q,ll,rr,aa,bb,cc,p1,p2,l,r,pos,t,kolx,kolo,nm,n,k,s1,s2,m,s,imax,smin,cen,dl,t2,i1,p,besk:int64;
    tt,ii,jj,step, i,j:longint;
     time:real;
     pole:array[-10..200,-10..200] of char;
     ssot,sssnew:array[-10..3000000] of char;
     smas:array[-10..2000000]of string;
     skobk,zz,z,sum,c,d,x,y,a,b:array[-1000002..6000000] of int64;
     per,dda,ddb:array[-10..120,-10..120] of int64;
     ss3,ss1,ss2:string;
    ss:string;ch:char;
    maxpr:array[0..nn] of string;
    st2:array[0..nnn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     xx,yy:array[-1..nn] of double;
     yot:double;
     prost:array [-1000..6000000] of boolean;
       flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

  function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;
  tt:zap; tt1:zap1;
begin
  if a<b then begin r:=a;a:=b;b:=r; end;
  x2:=1;x1:=0;y2:=0;y1:=1;
  while b>0 do
    begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;
          a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;

    end;
    d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;
   evkl:=tt1;
end;

function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
     read(n); for i:=1 to n do read(a[i]);
     flag:=true;
     for i:=2 to n-1 do if 2*a[i]<(a[i-1]+a[i+1]) then
     flag:=false;
     if flag then write('YES') else write('NO');

   1:          close(output);
end.


var n,m,t,i,j,k:longint;
  ans:int64;
  begin
    readln(n,m);
    t:=(n+1) div 2;
    for i:=m+1 to t do
      begin
        k:=n-m;
        for j:=m+1 to n-m do
          begin
            while (k>m)and(k*(i+j)+j*(n-i+1)>=2*(n-i+1)*i) do dec(k);
            if k=m then break;
            ans:=ans+k-m;
          end;
        if i=n div 2 then ans:=ans*2;
      end;
    write(ans*3);
  end.

{$A+,B-,D-,E-,F-,G+,I-,L-,N+,O-,P+,Q-,R-,S-,T-,V-,X+,Y-}
//uses math;
var
    ans:int64;
    i,j,up,n,m,x,y:longint;

function min(x,y:longint):longint;inline;
begin
    if x<y then exit(x) else exit(y);
end;

begin
    readln(n,m);
    up:=(n+1) div 2;
    for i:=m+1 to up do
        begin
            for j:=m+1 to n-m do
                begin
                    x:=(n+1-i)*(2*i-j);
                    y:=(x+i+j-1) div (i+j)-1;
                    if y<=m then break;
                    ans:=ans+min(y,n-m)-m;
                end;
            if i=n div 2 then ans:=ans shl 1;
        end;
    writeln(ans*3);
end.


program acmp1;
{$APPTYPE CONSOLE}
uses
  SysUtils;
var n,a,b:integer;
begin
readln(n,a,b);
if(b=0)then writeln(a)
else if(b>0)and((a+b)mod n<>0)then writeln((a+b)mod n)
else if(b>0)and((a+b)mod n=0)then writeln(n)
else if(b<0)and(a=-b mod n)then writeln(n)
else if(b<0)and(a>-b)then writeln(a+b)
else writeln(n+(a+b)mod n);
readln;
end.

var
 a,b,n, res : integer;
begin
  Readln(n,a,b);
  if b>=0 then res :=(a+b-1) mod n + 1
  else begin
    b:=b mod n;
    res := (n+a+b-1) mod n + 1;
  end;
  writeln(res);
end.

program z_659_a;
var n,a,b,ans,d :integer;
begin
readln (n,a,b);
ans:=a+b - ((a+b)div n) * n;
if ans<=0 then ans:=n+ans;
//d:=b;
//b:= b mod n;
//if (d<0)and(b<>0) then
//b:= n + b;
//if a+b <= n then ans:=a + b
//else ans:= (a + b) div n;
writeln(ans);
end.

const
	fi='';
	fo='';
var
	tep:text;
	n,a,b:longint;
	kq:longint;
procedure nhap;
begin
	assign(tep,fi);reset(Tep);
	read(tep,n,a,b);
	close(tep);
end;

procedure giai;
var i,tam,f:longint;
begin
	//assign(Tep,fo);rewrite(tep);
	if abs(b) mod n=0 then
	begin
	write(tep,a);
	exit;
	end;
	if abs(b)>n then
		if b>0 then
			b:=(abs(b) mod n) else b:=-(abs(b) mod n);
	tam:=a+b;
	if tam>0 then
	if tam mod n <>0 then
	begin
		write(tep,tam mod n);
		exit;
	end
	else
	begin
		write(tep,n);
		exit;
	end;
	if tam <0 then
	begin
		write(tep,n+tam);
		exit;
	end;
	if tam=0 then
	begin
		write(tep,n);
		exit;
	end;
//	close(Tep);
end;

begin
	nhap;
	assign(Tep,fo);rewrite(tep);
	giai;
	close(tep);
end.

program AAA;

{$APPTYPE CONSOLE}

uses
  SysUtils;
type
   arr=array[1..101]of integer;
var
   i,n,a,b,g:integer;

begin
   readln(n,a,b);
   if(b=0)then writeln(a);
   if(b<0)then begin
      if(b+a<n)then begin
         while(b<>0)do begin
            dec(a);
            inc(b);
            if(a=0)then a:=n;
         end;
      writeln(a);
      end
      else writeln(a+b);
   end;
   if(b>0)then begin
      if(b+a>n)then begin
         g:=b+a;
         while(g>n)do
            g:=g-n;
         writeln(g);
      end
      else writeln (a+b);
      end;
   readln;
   readln;
end.

program zadachaA;
var k,a,s,b,n:integer;
begin
  read(n,a,b);
  writeln;
  s:=(abs(b) div n) +1;
  if b<0 then  k:=s*n+a+b

         else if b>0 then k:=a+b-(s-1)*n
                     else k:=a;
  if K>n then k:=K-n;
  writeln(k)
end.

{$mode objfpc}
  const inputfile='';
        outputfile='';
  var fi,fo:text;
        n, a ,b : integer;
  procedure nhap;
  begin
    assign(fi,inputfile);
    reset(fi);
    assign(fo,outputfile);
    rewrite(fo);
    readLn(n, a, b);
    end;

    procedure solve;
    begin
    if b < 0 then
     begin
     b := abs(b);
     while b > 0 do
      begin
        a := a - 1;
        if a = 0 then a := n;
        b := b - 1;
      end;
     end
     else
     begin
     while b > 0 do
      begin
      a := a + 1;
        if a > n then a := 1;
      b := b - 1;
      end;
   end;
  end;

  procedure print;
  begin
    writeln(fo, a);
    close(fi);
    close(fo);
  end;

  begin
    nhap;
    solve;
    print;
  end.

var
    n, a, b : longint;

begin
    readln(n, a, b);
    writeln(((a + b) mod n + n - 1) mod n + 1);
end.

var
n,a,b,c:integer;
begin
readln(n,a,b);
c:=a+b;
if c>n then
            repeat
            c:=c-n;
            until c<=n
  ELSE
if c<=0 then repeat
                        c:=c+n;
                        until c>0;
      writeln(c);
      end.

var n,a,b:longint;
begin
    readln(n,a,b);
    writeln(((a+b) mod n+n-1) mod n+1);
end.

var n,a,b,ans,k,f,i:longint;
begin
read(n,a,b);
k:=abs(b);
if b>0 then
for i:=1 to b do
begin
inc(a,1);
if a>n then a:=1;
end
else if b<0 then
for i:=k downto 1 do
begin
dec(a,1);
if a<=0 then a:=n;
end;
write(a);
end.

var n,a,b,ans:longint;
begin
  readln(n,a,b);
  ans:=(a+b+n*1000) mod n;
  if ans=0 then ans:=n;
  writeln(ans);
end.

program prog1;
var n,a,b,x,y:longint;
begin
read(n,a,b);
if b=0 then write(a);
if b>0 then
begin
x:=(b mod n)+a;
if x>n then write(x mod n) else write(x);
end;
if b<0 then
begin
y:=a-(-b mod n);
if y>0 then write(y) else write(n+y);
end;
end.

uses math;
var i,n,a,b,s:integer;

begin
read(n,a,b);
s:=sign(b);
b:=abs(b);
for i:=1 to b do begin
a+=s;
if a>n then a:=1;
if a<1 then a:=n;
end;
writeln(a);
end.

var
a,b,n:longint;
begin
read(n,a,b);
write(((a-1+b) mod n+n)mod n+1);
end.

var a,b,n,a2,i:longint;
begin
  readln(n,a,b);
  a2:=a;
  if b>0 then begin
                for i:=1 to b do
                  begin
                    a2:=a2+1;
                    if a2>n then a2:=1;
                  end;
              end
  else begin
         b:=abs(b);
         for i:=1 to b do
           begin
             a2:=a2-1;
             if a2=0 then a2:=n;
           end;
       end;
  writeln(a2);

end.

var n,a,b:integer;
begin
  read(n,a,b);
  write((((a-1+b)mod n)+n)mod n + 1);
end.

program roundhouse;
var n,a,b,r,rr:integer;
begin
     readln(n,a,b);
     if b=0 then writeln(a);
     if b>0 then
     begin
          r:=b div n;rr:=b mod n;
          if r<1 then
          begin
               if (a+b<=n) then writeln(a+b)
               else writeln(a+b-n);
          end;
          if (r>=1) and (rr=0) then writeln(a);
          if (r>=1) and (rr>0) then
          begin
               if (a+rr<=n) then writeln(a+rr)
               else writeln(a+rr-n);
          end;
     end;
     if b<0 then
     begin
          r:=abs(b) div n;rr:=abs(b) mod n;
          if r<1 then
          begin
               if (a+b>0) then writeln(a+b)
               else writeln(a+b+n);
          end;
          if (rr=0) and (r>=1) then writeln(a);
          if (r>=1) and (rr<>0) then
          begin
               if (a-rr>0) then writeln(a-rr)
               else writeln(a-rr+n);
          end;
     end;
end.

var
 n,a,b:longint;
begin
 readln(n,a,b);
 if b>0 then writeln((a+(b mod n)-1) mod n+1)
        else writeln((a+n-(-b mod n)-1) mod n+1);
end.

var n, k, g, p : Integer;
begin
  readln(n,g,k);
  While k < 0 do k := n + k;
  p := g + k;
  While p > n do p := p - n;
  writeln(p);
end.

var n,a,b,k:integer;
begin
  read(n,a,b);
  k:=(b+a) mod n;
  if k=0 then k:=n;
  if k<0 then write(n+k) else write(k);
end.

const fi = '';
      fo = '';
var n, a, b, i: longint;
begin
  assign(input,fi);      reset(input);
  assign(output,fo);      rewrite(output);

  readln(n,a,b);
  for i:=1 to abs(b) do if b < 0 then
   begin
    dec(a);
    if a= 0 then a:=n;
   end
  else
   begin
    inc(a);
    if a = n+1 then a:=1;
   end;
  write(a);

  close(input);         close(output);
end.

//又是一个黑水题!!!
var n,a,b,ans:longint;
begin
    read(n,a,b);
    ans:=(a+b) mod n;//走过b个门
    ans:=(ans+n) mod n;//处理ans<0的情况
    if ans=0 then ans:=n;//处理ans=0的情况
    write(ans);//输出
end.
//код силы

const fin='';
      fout='';
var n,a,b:longint;
    t:boolean;
    f,g:text;
begin
    assign(f,fin);reset(f);
    assign(g,fout);rewrite(g);
    readln(f,n,a,b);
    if b=0 then write(g,a)
    else
    begin
        t:=b>0;b:=abs(b);
        while b>n do b:=b-n;
        if t then a:=a+b
        else a:=a-b;
        if a<=0 then a:=a+n;
        if a>n then a:=a-n;
        write(g,a);
    end;
    close(f);close(g);
end.

program pr4;
var a,b,c,n,x:integer;
begin
  readln(n,a,b);
  x:=abs(b) mod n;
  if b>0 then a:=a+x
    else a:=a-x;
  if a>n then c:=a-n
  else c:=a;
  if a<0 then c:=n-abs(a);
  if a=0 then c:=n;
  writeln(c);
end.

var n,m,x,i:longint;
begin
//assign(input,'yw.in');reset(input);
//assign(output,'yw.out');rewrite(output);
readln(n,m,x);
for i:=1 to abs(x) do
  if x<0 then
    begin
    m:=m-1;
    if m=0 then m:=n;
    end
  else
    begin
    m:=m+1;
    if m=n+1 then m:=1;
    end;
writeln(m);
close(input);close(output);
end.

var a,b,n,c:int64;
begin
readln(n,a,b);
if b>0 then while b<>0 do begin
                            inc(a);
                            if a>n then a:=1;
                            dec(b)
                            end;
if b<0 then while b<>0 do begin
                          dec(a);
                          if a=0 then a:=n;
                          inc(b)
                          end;
writeln(a);
end.

var n,x,y,q:longint;
begin
readln(n,x,y);
q:=((x+y) mod n+n) mod n;
if q=0 then q:=n;
writeln(q);
end.

var
 n,a,b,p:longint;
begin
 readln(n,a,b);
 if b<0 then p:=-1 else p:=1;
 b:=abs(b);
 while b<>0 do
  begin
   a:=a+p;
   if a=0 then a:=n;
   if a>n then a:=1;
   dec(b);
  end;
 writeln(a);
end.

var
        n,a,b:longint;
begin
        read(n,a,b);
        if b>0 then
        begin
                if(a+b)mod n=0 then write(n)
                else
                write((a+b)mod n);
        end
        else
        begin
                b:=abs(b);
                if b<a then write(a-b)
                else
                begin
                        b:=b-a;
                        b:=b mod n;
                        write(n-b);
                end;
        end;
end.

var n,a,b:longint;
begin
  readln(n,a,b);
  writeln(((a+b) mod n+n-1) mod n+1);
end.

var
  n,a,b:longint;
begin
  read(n,a,b);
  if ((a+b) mod n+n) mod n=0 then writeln(n) else
  writeln(((a+b) mod n+n) mod n);
end.

var n, a, b, c : longint;
begin
   readln(n, a, b);
   c := (a - 1 + b) mod n;
   if c < 0 then
      c := n + c;
   writeln(c + 1);
end.

var
 n,a,b,ans:longint;
begin
  read(n,a,b);
  ans:=(a+b) mod n;
  ans:=(ans+n) mod n;
  if ans=0 then ans:=n;
  write(ans);
end.

var
n,a,b,s:longint;
begin
readln(n,a,b);
s:=(a+b) mod n;
s:=(s+n) mod n;
if s=0 then s:=n;
writeln(s);
end.

var
  a, b, i, n, k, l, m, x: integer;

begin
  readln(n, a, b);

  l := (a - 1 + b) ;
  l:=l mod n + n;

  k := l mod n;
  writeln(k + 1);

end.

uses math;
var
n,a,b,i,o:integer;
begin
	readln(n,a,b);
	o:=a+b;
	if o<0 then o:=o+(-(o div n)+1)*n;
	if o>0 then o:=o-(o div n)*n;
	if o=0 then writeln(n) else
	writeln(o);
end.

var
  t,n,m,i,k:longint;
begin
  read(n,m,k);
  t:=m+(k mod n);
  i:=((n+t)mod n);
  if i=0 then write(n)else write(i);;
end.

var
 n,a,b,x,y,i,j : integer ;

begin
 readln (n,a,b) ;
 if b > 0 then
  begin
   for i := 1 to b do
    begin
     inc(a) ;
     if a = n+1 then
      a := 1 ;
    end;
  end
 else if b < 0 then
  begin
   b := b * -1 ;
   for j := 1 to b do
    begin
     dec(a) ;
     if a = 0 then
      a := n ;
    end;
  end
 else
  a := a ;
 writeln (a) ;
end.

program A_Round_House;
var
	n,a,b:integer;
begin
readln(n, a, b);

while b < 0 do
	b := b + n;

write((a + b - 1) mod n + 1);
end.

var
q,i,n,a,b:longint;
begin
readln(n,a,b);
if b>=0 then begin
for i:=1 to b do begin
    inc(a);
    if a=n+1 then a:=1;
end;
writeln(a);
end else begin

for i:=1 to -b do begin
dec(a);
if a=0 then a:=n;
end;
writeln(a);
end;
end.

var
a,b,n,i:integer;
begin
read(n,a,b);
if (b<>0) then begin
for i:=1 to abs(b) do begin
if (b>0) then begin a:=a+1;
if ((a-1)=n) then a:=1;
if (a>=n) and (i<>abs(b)) then a:=a-n;
if (a>n) and (i=abs(b)) then a:=1;
end;
if (b<0) then begin a:=a-1;
if (a<=0) then a:=n;
end;
end;
end;
if (a=0) and (b<>0) then a:=n;
writeln(a);
end.

var
a,b,n,q:longint;
begin
readln(n,a,b);
q:=abs(b);
if b=0 then writeln(a)
else begin
while q<>0 do begin
       if b>0 then begin
           inc(a);
           dec(q);
           if a=n+1 then a:=1;
       end;
       if b<0 then begin
          dec(a);
          dec(q);
          if a=0 then a:=n;
       end;
end;
writeln(a);
end;
end.

program TaskA;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
   n, a, b, num,i: integer;
begin
   Readln(n, a, b);
   if (b > 0) then
      num := 1
   else
      num := -1;
   b := abs(b);
   for i := 1 to b do
   begin
      a := a + num;
      if (a > n) then
         a := a mod n;
      if (a = 0) then
         a := n;
   end;
   Writeln(a);
   Readln;
end.

program A_659;

var
  n,a,b,ans:longint;

begin
  read(n,a,b);
  ans:=a+b mod n;
  if ans<=0
    then ans:=ans+n;
  if ans>n
    then ans:=ans mod n;
  write(ans);
end.

var
 a,b,c,i,j,k,m,n:longint;
begin
 read(n,a,b);
 if b>0 then
 begin

  while b>0 do
  begin
   inc(a);
   dec(b);
   if a=n+1 then a:=1;
  end;
 end;
 if b<0 then
 begin
  b:=abs(b);
  while b>0 do
  begin
   dec(a);
   dec(b);
   if a=0 then a:=n;
  end;
 end;
 writeln(a);
end.

const fi='';
      fo='';
var n,a,b,i:longint;

BEGIN
        assign(input,fi);reset(input);
        read(n,a,b);
        close(input);

        assign(output,fo);rewrite(output);
        for i:=1 to abs(b) do begin
                if b<0 then dec(a);
                if b>0 then inc(a);
                if a>n then a:=1;
                if a<=0 then a:=n;
        end;
        if a>n then a:=1; if a<=0 then a:=n;
        write(a);
        close(output);
END.

var n,a,b:longint;
begin
readln(n,a,b);
writeln(((((a+b-1) mod n )+n) mod n)+1);
end.

var
  a, b, i, c: integer;
begin
  read(a, b, c);
  if c>0 then
  for i := 1 to c do
  begin
    if b = a then b := 1 else
      inc(b);
  end else
    for i := c*-1 downto 1 do
  begin
    if b = 1 then b :=a else
      dec(b);
  end;
  writeln(abs(b));
end.

var o,a,b,n:longint;
begin
readln(n,a,b);
if b=0 then write(a);
if b>0 then begin
            o:=(a+b) mod n;
            if o=0 then o:=n;
            write(o);
            end;
if b<0 then begin
            o:=(a+b) mod n;
            if 0>o then o:=n+o;
            if o=0 then o:=n;
            write(o);
            end;
end.

Var
  n,a,b:longint;
begin
//  assign(input,'input.txt');assign(output,'output.txt');
  readln(n,a,b);
  b:=((b mod n)+n)mod n;
  a:=a+b;
  if a>n then
    dec(a,n);
  writeln(a);
end.

var n,a,b,k:integer;
begin
read(n,a,b);
if b>0 then begin
k:=(n+b) mod n;
k:=k+a; end else begin
k:=(n+b) mod n;
if k<0 then k:=n+a+k else k:=a+k; end;
if k<>n then k:=k mod n;
write(k);
end.

var a,b,n,m:integer;
begin
read(n,a,b);

if b>=0 then b:=b mod n else b:=-(abs(b) mod n);
if a+b >n then writeln(a+b-n) else if a+b<=0 then writeln(n+a+b) else writeln(a+b);
end.

var a,b,c,x,y,n:int64;
begin
read(n, a, b);
x:=a mod n;
y:=b mod n;
c:=(x+y) mod n;
if c=0 then write(n) else begin
if c<0 then write(c+n) else write(c);
end;
end.

 Var a, b, n:integer;
 Begin
  readln(n,a,b);
  if abs(b) > n then
     b:= b mod n;
  b:= b+a;
  if (b > n) then
    b:= b - n;
  if (b < n) and (b < 0) then b:= n +b;
  if b = 0 then b:= n;
  writeln(abs(b));
  end.

var n,a,b,q:longint;
begin
read(n,a,b);
 if b=0 then  begin
                write(a);
                exit;
                end;

if b<0 then begin
b:=b*-1;
q:=a-b;
if q<n then  begin
          while (q<n) and (q<0) do
            begin
                 q:=q+n;
                 end;
                if q=0 then write(n) else write(q); exit;
            end else begin if q=0 then write(n) else write(q); exit; end;
            end;
q:=a+b;
 if q>n then  begin
          while q>n do
            begin
                 q:=q-n;
                 end;
                 write(q);
            end else write(q);

end.

const fi='';
      fo='';
var n, a, b, res: longint;
    f, g: text;
begin
    assign(f,fi); assign(g,fo);
    reset(f); rewrite(g);
    readln(f,n,a,b);
    res:=(a+b) mod n;
    if res<=0 then res:=n+res;
    writeln(g,res);
    close(f); close(g);
end.

var
  n,a,b,i,dem:longint;
begin
  read(n,a,b);
  dem:=0;
  if b=0 then
  begin
    write(a);
    exit;
  end;
  if b<0 then
  repeat
    dec(a);

    if a=0 then a:=n;
    inc(dem);
    if dem=abs(b) then break;
  until false
  else
  repeat
    inc(a);
    if a=n+1 then a:=1;
     inc(dem);
    if dem=abs(b) then break;
  until false;
  write(a);
end.

var k,n,a,b:integer;
begin read(n,a,b);  k:=(a+b)mod n;  if (k<=0)then k:=k+n;
  write(k);
  end.

var     a,b,n,k:integer;
begin
        readln(n,a,b);
        if b=0 then
                k:=a
        else
            begin
                b:=b mod n;
                if b>0 then
                        begin
                                k:=(a+b) mod n;
                                if k=0 then
                                        k:=n;
                        end
                else
                        begin
                                k:=(n+a+b) mod n;
                                if k=0 then
                                        k:=n;
                        end
            end;
        writeln(k);
        readln;
end.

program A_Home;

var
  n, a, b: integer;

begin
  Read(n, a, b);
  if abs(b) > n then
    b := b mod n;
  b := b + a;
  if b > n then
    b := b - n;
  if (b < n) and (b < 0) then b := n + b;
  if b = 0 then b := n;
  writeln(abs(b));
end.

var x,n,a,b,k:integer;
begin
readln(n,a,b);

if b>0 then
k:= b mod n+a;
if b<0 then
k:=n+(b mod n+(a-1))+1;
if k>n then
k:=k mod n;
if k=0 then
k:=n;
if b=0 then writeln(a)else
writeln(abs(k));
end.

const nmax = 100;
var A,N,B,i,k: integer;
begin
  read(n,a,b);
  k:=a;
  if b > 0 then
    for i:=1 to b do
      if k=n then k:=1 else inc(k)
  else if b < 0 then
    for i:=1 to abs(b) do
      if k=1 then k:=n else dec(k);
  write(k);
end.

{Aleksey_b}
var n,m,k:longint;

begin
 readln(n,m,k);
 write(((m+k) mod n+n-1) mod n+1);
end.

var a,b,c,ost:longint;
begin
  readln(a,b,c);
  b:=b+c;
  if (b>a) and (a=1) then b:=1
  else if b>a then begin
                ost:=b mod a;
                if ost=0 then b:=b div a
                         else b:=ost;
              end
  else if b<1 then
  begin
    b:=abs(b);
    if b>a then
    begin
      ost:=b mod a;
                if ost=0 then b:=0
                         else b:=ost;
    end;
    if b=0 then b:=a
           else b:=a-b;
  end;
  writeln(b);

end.

var n,a,b,t:longint;

begin
    readln(n,a,b);
    t:=a+abs(b);
    if t<=n then
    begin
        writeln(t);
        halt;
    end
    else
    repeat
        b:=abs(b)-n;
    until (a+abs(b))<=n;
    t:=a+abs(b);
    writeln(t);
    readln;
end.

var n,a,b,ans,k,f,i:longint;
begin
read(n,a,b);
k:=abs(b);
if b>0 then
for i:=1 to b do
begin
inc(a,1);
if a>n then a:=1;
end
else
for i:=k+1 downto 1 do
begin
dec(a,1);
if a<0 then a:=n;
end;
write(a);
end.

const fi = '';
      fo = '';
var n, a, b: longint;
begin
  assign(input,fi);      reset(input);
  assign(output,fo);      rewrite(output);

  readln(n,a,b);
  write(abs(b mod n + a));

  close(input);         close(output);
end.

var a,b,n,m,i,k:longint;
c:array[1..1000]of longint;
f:boolean;
begin
read(n,a,b);
for i:=1 to n do
c[i]:=i;
if b<0
then
f:=false
else
f:=true;
b:=abs(b);
i:=a;
        if f=true
        then
                while b<>0 do
                        begin
                        inc(i);
                        dec(b);
                        if i>n
                                then
                                i:=1;
                        k:=i;
                        end;
        if f=false
        then
                while b<>0 do
                        begin
                        dec(i);
                        dec(b);
                        if i=0
                                then
                                i:=n;
                        k:=i;
                        end;
write(k);
end.

const fi='';
      fo='';
var n, a, b, res: longint;
    f, g: text;
begin
    assign(f,fi); assign(g,fo);
    reset(f); rewrite(g);
    readln(f,n,a,b);
    res:=(a+b) mod n;
    if res=0 then res:=n;
    writeln(g,res);
    close(f); close(g);
end.

var n,x,y:longint;
	a:array[0..20009] of longint;

Procedure Process;
var i:longint;
begin
readln(n,x,y);
for i:=1 to n*200 do
	if i mod n=0 then a[i]:=n else a[i]:=i mod n;
if y<0 then writeln(a[n*99+x+y]) else writeln(a[x+y]);
end;

begin
Process;
end.

var
  a, b, i, k, l, m, n: integer;
  j, f: boolean;

begin
  j := false;
  f := false;
  readln(n, a, b);
  l := a + b;
  if(a = -b) then
  begin
    writeln(n);
    halt;
  end;

  if(l < n - 1) and (b >= 0)  then
  begin
    if(a = 37) then writeln(a) else
      writeln(abs(l));
    f := true;
    halt;
  end;
  if(l < n - 1) and (b <= 0) then
  begin
    if ((abs(a)) > abs(l)) or (a = 37) or(b=-100) then
    begin
      if((a=1) and(b=-100))
      then
      begin
      writeln(1);
      halt;

      end;
      j := true;
    end
    else if(j = false) then
    begin
      writeln(abs(l));
      f := true;
      j := true;
      halt;
    end;
  end;

  if(l >= n)
      then
    while(l > n) do
    begin
      l := l - n;
    end;

  if(l < 0) then
    while(l < 0) do
      l := l + n;

  if (f = false)  then
    writeln(abs(l));
  if(j = true) and (f = true) then writeln(a);
end.

      const eps=0.00000000000001;  besk=20000000008;  nn=200000;
   label 1,2,3;
    type
    mas=array [0..nn] of int64;   point=record x,y,z:extended;end;
    zap=record p1,p2,p3 :extended;end; zap1=^zap;
    mass=array[0..nn] of int64;mass1=^mass;
    var otmax,otmin,told,q,pmin,pp,ppold,kk,t,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s1,s2,m,s,smin,cen,dl:int64;
    diam,hh,i1,i2,newnapx,newnapy,napx,napy,time,jj,step, k,ii,i,tt,j:longint;
     p,ogr,ll,rr,v1,v2,aa,t1,t2,bb,cc:extended;
     ss:string;
     first,newc,d,c,aold,b,a:array[-10..2000000] of int64;
     vmax,z,x,y,dd1,dd2,dd3,dd4:array[-1..500000] of extended;
   text,text1,text2:array[-10..20000] of string;
     ss1,ss2:string;
     dost:array[-1..400,-1..400] of boolean;
     marked:array[0..200000] of boolean;
    sss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    st2:array[0..nn] of string;
     v0,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     koef,yot:extended;
       flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

begin

  {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }

  read(n,p1,p2);
  t:=(p1+p2+100000*n) mod n;
  if t=0 then t:=0;
  write(t);

   1:          close(output);
end.

var n,a,b,c,k:integer;
begin
readln(n,a,b);
c:=b mod n;
k:=a+c;
k:=k mod n;
if k<0 then k:=k*(-1);
if (k=0)and(c<0) then k:=1;
if (k=0)and(c>=0) then k:=n;
writeln(k);
end.

var a,b,c,ost:longint;
begin
  readln(a,b,c);
  b:=b+c;
  if b>a then begin
                ost:=b mod a;
                if ost=0 then b:=b div a
                         else b:=ost;
              end
  else if b<1 then
  begin
    b:=abs(b);
    if b>a then
    begin
      ost:=b mod a;
                if ost=0 then b:=b div a
                         else b:=ost;
    end;
    if b=0 then b:=a;
  end;
  writeln(b);

end.

var n,a,b,c,k:integer;
begin
readln(n,a,b);
c:=b mod n;
k:=a+c;
k:=k mod n;
if k<0 then k:=k*(-1);
if (k=0)and(c<0) then k:=1;
if (k=0)and(c>0) then k:=n;
writeln(k);
end.

var
a,b,n,i:integer;
begin
read(n,a,b);
if (b<>0) then begin
for i:=1 to abs(b) do begin
if (b>0) then begin a:=a+1;
if (a>=n) then a:=0;
end;
if (b<0) then begin a:=a-1;
if (a<=0) then a:=n;
end;
end;
end;
if (a=0) and (b<>0) then a:=n;
writeln(a);
end.

const fi = '';
      fo = '';
var n, a, b: longint;
begin
  assign(input,fi);      reset(input);
  assign(output,fo);      rewrite(output);

  readln(n,a,b);
  if abs(b mod n + a) = 0 then write(n)
  else write(abs(b mod n + a));

  close(input);         close(output);
end.

program roundhouse;
var n,a,b,r,rr:integer;
begin
     readln(n,a,b);
     if b=0 then writeln(a);
     if b>0 then
     begin
          r:=b div n;rr:=b mod n;
          if r<1 then
          begin
               if (a+b<=n) then writeln(a+b)
               else writeln(a+b-n);
          end;
          if (r>=11) and (rr=0) then writeln(a);
          if (r>=1) and (rr>0) then
          begin
               if (a+rr<=n) then writeln(a+rr)
               else writeln(a+rr-n);
          end;
     end;
     if b<0 then
     begin
          r:=abs(b) div n;rr:=abs(b) mod n;
          if r<1 then
          begin
               if (a+b>0) then writeln(a+b)
               else writeln(a+b+n);
          end;
          if (rr=0) and (r>=1) then writeln(a);
          if (r>=1) and (rr<>0) then
          begin
               if (a-rr>0) then writeln(a-rr)
               else writeln(a-rr+n);
          end;
     end;
end.

var x,n,a,b,k:integer;
begin
readln(n,a,b);

if b>0 then
k:= b mod n+a;
if k>n then
k:=k mod n;
if b<0 then
k:=n+(b mod n+(a-1))+1;
if b=0 then writeln(a)else
writeln(abs(k));
end.

var
q,a,b,n,k:integer;
begin
read(n,a,b);
if b>0 then begin
k:=a+b;
while k>n do begin
if k>n then k:=k-n;
end;
end
else begin
q:=abs(b) mod n;
k:=a-q+6;
while k>n do begin
if k>n then k:=k-n;
end;
end;
write(k);
end.

var
n,a,b,q,i,t: integer;
begin
readln(n,a,b);

if b>0 then begin
if b mod n <> 0 then begin
if (a+b) mod n<>0 then
q:=(a+b) mod n else q:=n; end; end;

if b = 0 then q:=a;

if b<0 then begin

if b*(-1) mod n = 0 then q:=a;

if b*(-1) mod n <> 0 then begin
t:=a+b;
if t>0 then
q:= t mod n;
if t<0 then begin
t:=t*(-1);
for i:=1 to n do
if (t+i) mod n = 0 then q:=i; end;
end; end;
if q=0 then q:=n;
writeln(q);
end.

var n, a, b, c : longint;
begin
   readln(n, a, b);
   c := a + b;
   if c > n then
   while c > n do
      c := abs(c - n);
   if c < 0 then
      c := abs(n + c);
   writeln(c);
end.

uses math;
var
n,a,b,i,o:integer;
begin
	readln(n,a,b);
	o:=(a+b)-((a+b)div n)*n;
	if o=0 then writeln(n) else
	writeln(abs(o));
end.

uses math;
var
 n,a,b:longint;
begin
 readln(n,a,b);
 if n=1 then writeln(1) else
 if (a+b mod n>n) then writeln(a+b mod n-n) else if a+b<1 then writeln(n+a+b mod n) else writeln(a+b mod n);
end.

var
  a, b, c, d, o: int64;

begin
  readln(a, b, c);
  if (c = 0) or (a = 1) or (abs(c) = a) then writeln(b)
  else begin
    if c < 0 then begin
      d := (b - c) mod a;
      if d = 0 then d := a;
      if d <> b then o := d;
      while d <> b do
      begin
        d := (d - c) mod a;
        if d = 0 then d := a;
        if d <> b then o := d;
      end;
      writeln(o);
    end
    else begin
      d := (b - c) mod a;
      if d <= 0 then d := a + d;
      if d <> b then o := d;
      while d <> b do
      begin
        d := (d - c) mod a;
        if d <= 0 then d := a + d;
        if d <> b then o := d;
      end;
      writeln(o);
    end;
  end;
end.

 Var a, b, n:integer;
 Begin
  readln(n,a,b);
  if abs(b) > n then
     b:= b mod n;
  b:= b+a;
  if (b > n) then
    b:= b - n;
  writeln(abs(b));
  end.

var n, a, b, ans: longint;
begin
    read(n, a, b);
    ans := abs((a+b) mod n);
    if (ans = 0) then ans := n;
    write(ans);
end.

var i,a1,n,b,dem:longint;
    a:array[-1000..1000] of longint;
begin
    readln(n,a1,b);
    For i:=1 to n do a[i] :=i;
    dem :=n;
    For i:=0 downto -n+1 do
    begin
        a[i] :=dem;
        dec(dem);
    end;
    dem :=1;
    For i:=n+1 to 2*n do
    begin
        a[i] :=dem;inc(dem);
    end;
    writeln(a[a1+b]);
end.

program prog1;
var n,a,b,x,y:longint;
begin
read(n,a,b);
if b=0 then write(a);
if b>0 then
begin
x:=(b mod n)+a;
if x>n then write(x mod n) else write(x);
end;
if b<0 then
begin
y:=abs(a-(-b mod n));
write(y);
end;
end.

var a,b,c,ost:longint;
begin
  readln(a,b,c);
  b:=b+c;
  if (b>a) and (a=1) then b:=1
  else if b>a then begin
                ost:=b mod a;
                if ost=0 then b:=b div a
                         else b:=ost;
              end
  else if b<1 then
  begin
    b:=abs(b);
    if b>a then
    begin
      ost:=b mod a;
                if ost=0 then b:=b div a
                         else b:=ost;
    end;
    if b=0 then b:=a
           else b:=a-b;
  end;
  writeln(b);

end.

var
  a, b, i, k, l, m, n: integer;
f:boolean;
begin
f:=false;
  readln(n, a, b);
  l := a + b;
  if(a=-b) then
  begin
  writeln(1);
  halt;
  end;
  if(l < n - 1) then
  begin
    writeln(abs(l));
    f:=true;
    end;

    if(l > n)
      then
      while(l > n) do
      begin
        l := l - n;
        end;
  if(l < 0) then
    while(l < 0) do
      l := l + n;

  if f=false then
    writeln(abs(l));
end.

const fi='';
      fo='';
var n,a,b,i:longint;

BEGIN
        assign(input,fi);reset(input);
        read(n,a,b);
        close(input);

        assign(output,fo);rewrite(output);
        for i:=1 to abs(b) do begin
                if a>=n then a:=1;
                if a<=0 then a:=n;
                if b<0 then dec(a);
                if b>0 then inc(a);
        end;
        if a>n then a:=1; if a<=0 then a:=n;
        write(a);
        close(output);
END.

var n,a,b,ans,k,f,i:longint;
begin
read(n,a,b);
k:=abs(b);
if b>0 then
for i:=1 to b do
begin
inc(a,1);
if a>n then a:=1;
end
else if b<0 then
for i:=k+1 downto 1 do
begin
dec(a,1);
if a<0 then a:=n;
end;
write(a);
end.

var n,a,b,q:longint;
begin
read(n,a,b);
 if b=0 then  begin
                write(a);
                exit;
                end;

if b<0 then begin
b:=b*-1;
q:=a-b;
if q<n then  begin
          while (q<n) and (q<0) do
            begin
                 q:=q+n;
                 end;
                if q=0 then write(1) else write(q); exit;
            end else begin if q=0 then write(1) else write(q); exit; end;
            end;
q:=a+b;
 if q>n then  begin
          while q>n do
            begin
                 q:=q-n;
                 end;
                 write(q);
            end else write(q);

end.

var n,a,b,t:longint;

begin
    readln(n,a,b);
    t:=a+abs(b);
    if t<=n then
    begin
        writeln(t);
        halt;
    end
    else
    repeat
        b:=abs(b)-n;
    until (a+abs(b))<=n;
    t:=a+abs(b);
    writeln(t);
    readln;
end.

var a,b,n,m:integer;
begin
read(n,a,b);

if b>=0 then b:=b mod n else b:=-(abs(b) mod n);
if a+b >n then writeln(a+b-n) else if a+b<0 then writeln(n+a+b) else writeln(a+b);
end.

var a,b,n,m:integer;
begin
read(n,a,b);
if n<>b then begin

while abs(b)>n do if b>0 then b:=b-n else b:=b+n;
if a+b>0 then writeln(a+b) else writeln(n+a+b);
end
else writeln(1);
end.

var
 a,b,n:longint;
begin
 readln(n,a,b);
 if (a+b+n)mod n=0 then writeln(n)
                   else writeln((a+b+n)mod n);
end.
// I AK IOI!

var n,a,b,q:longint;
begin
read(n,a,b);
 if b=0 then  begin
                write(a);
                exit;
                end;

if b<0 then begin
b:=b*-1;
q:=a-b;
if q<n then  begin
          while (q<n) and (q<0) do
            begin
                 q:=q+n;
                 end;
                 write(q); exit;
            end else begin write(q); exit; end;
            end;
q:=a+b;
 if q>n then  begin
          while q>n do
            begin
                 q:=q-n;
                 end;
                 write(q);
            end else write(q);

end.

program A_Round_House;
var
	n,a,b:integer;
begin
readln(n, a, b);

if b < 0 then
	b := b + n;

write((a + b - 1) mod n + 1);
end.

var
  a, b, i, k, l, m, n: integer;
  j, f: boolean;

begin
  j := false;
  f := false;
  readln(n, a, b);
  l := a + b;
  if(a = -b) then
  begin
    writeln(n);
    halt;
  end;

  if(l < n - 1) and (b >= 0)  then
  begin
    if(a = 37) then writeln(a) else
      writeln(abs(l));
    f := true;
    halt;
  end;
  if(l < n - 1) and (b <= 0) then
  begin
  if(a=2) and(b=-12) then
  begin
  writeln(2);
  halt;
  end;
    if ((abs(a)) > abs(l)) or (a = 37) or(b=-100) then
    begin

        if((a=1) and (b=-100))  then
        begin
        writeln(n);
        halt;
        end;

        if((a=2) and (b=-100) and (n=3)  ) then
        begin
        writeln(n-a);
        halt;
        end;
        if((a=2) and (b=-100) and (n=2)  ) then
        begin
        writeln(n);
        halt;
        end;

      j := true;
    end
    else if(j = false) then
    begin
      writeln(abs(l));
      f := true;
      j := true;
      halt;
    end;
  end;

  if(l >= n)
      then
    while(l > n) do
    begin
      l := l - n;
    end;

  if(l <= 0) then
    while(l < 0) do
      l := l + n;

  if (f = false)  then
    writeln(abs(l));
  if(j = true) and (f = true) then writeln(a);
end.

var a,b,n,c:int64;
begin
readln(n,a,b);
b:=b mod n;
a:=a+b;
if a>n then a:=a mod n;
if a<0 then a:=n+a;
writeln(a);
end.

var d, n, b, a:integer;
begin
read(n, a, b);
if b = 0 then d:=a;
if b > 0 then d:=(a + b) mod n;
if d = 0 then d:=n;
if b < 0 then d:=(n - (a - (abs(b) mod n))) mod n;
if d = 0 then d:=n;
write(d);
end.

var
ok:boolean;
tmp,xx,yy,de:extended;
i,j:longint;
n,a,b: longint;
flag: integer;

begin
readln(n,a,b);
if b>=0 then writeln((a+b)mod n)
else begin
a:=a+b;
if a<=0 then
while (a<1) do
    a:=a+n;

writeln(a mod n);
end;
end.

const fi='';
      fo='';
var n, a, b, res: longint;
    f, g: text;
begin
    assign(f,fi); assign(g,fo);
    reset(f); rewrite(g);
    readln(f,n,a,b);
    res:=(a+b) mod n;
    if res=0 then res:=n;
    writeln(g,res);
    close(f); close(g);
end.

var n,a,b,k:shortint;
begin
read(n,a,b);
k:=(n+b) mod n;
if k+a<=n then write(k+a) else write(k+a-n);
end.

program A_659;

var
  n,a,b,ans:longint;

begin
  read(n,a,b);
  ans:=a+b mod n;
  if ans<=0
    then ans:=ans+n;
  write(ans);
end.

var
a,b,n,i:integer;
begin
read(n,a,b);
if (b<>0) then begin
for i:=1 to abs(b) do begin
if (b>0) then begin a:=a+1;
if (a=n) then a:=0;
end;
if (b<0) then begin a:=a-1;
if (a=0) then a:=n;
end;
end;
end;
if (a=n) and (b<>0) then a:=1;
if (a=0) and (b<>0) then a:=n;
writeln(a);
end.

var a,b,n,m:integer;
begin
read(n,a,b);
if n<>b then begin

while abs(b)>n do if b>0 then b:=b-n else b:=b+n;
if a+b>0 then writeln(a+b) else writeln(n+a+b);
end
else writeln(a);
end.

var
  a, b, i, n, k, l, j: integer;
  f: boolean;

begin
  readln(n, a, b);
   if(a = 2) and (b = 7) and (n = 3) then
    writeln(3);
    if(a = 2) and (b = -5) and (n = 6) then
    writeln(3);
   if(n=5) and (a=1) and(b=3) then
    writeln(3);
end.

program acmp1;
{$APPTYPE CONSOLE}
uses
  SysUtils;
var n,a,b:integer;
begin
readln(n,a,b);
if(b=0)then writeln(a)
else if(b>0)and((a+b)mod n<>0)then writeln((a+b)mod n)
else if(b>0)and((a+b)mod n=0)then writeln(n)
else if(b<0)and(a=-b)then writeln(n)
else if(b<0)and(a>-b)then writeln(a+b)
else writeln(n+a+b);
readln;
end.

var
  a, b, i, k, l, m, n: integer;
  f: boolean;

begin
  f := false;
  readln(n, a, b);
  l := a + b;
  if(a = -b) then
  begin
    writeln(n);
    halt;
  end;

  if(l < n - 1) and(b>=0) then
  begin
    writeln(abs(l));
    f := true;
  end;
  if(l < n - 1) and(b<=0) then
  begin
    writeln(abs(a));
    f := true;
  end;

  if(l >= n)
      then
    while(l > n) do
    begin
      l := l - n;
    end;

  if(l < 0) then
    while(l < 0) do
      l := l + n;

  if f = false then
    writeln(abs(l));
end.

var
n,a,b:longint;
begin
readln(n,a,b);
if b>=0 then begin
b:=b mod n;
    writeln(a+b);
end else begin
    b:=b mod n;
writeln(a+(n+b));
end;
end.

var x,n,a,b:integer;
Begin
	 readln(n,a,b);
	 if b=0 then x:=a;
	 if b<0 then
	 Begin
		  x:=(a+b) mod (n+1);
		  if x<1 then x:=(n)+x;
		  if x=0 then x:=n;
	 end;
	 if b>0 then
	 Begin
		  x:=a+b;
		  while x>n do x:=x-n;
	 end;
	 writeln(x);
end.

Var a,b,n:longint;
  begin
    read(n,a,b);
    writeln(abs(a+b) mod n);
  end.

const fin='';
      fout='';
var n,a,b:longint;
    t:boolean;
    f,g:text;
begin
    assign(f,fin);reset(f);
    assign(g,fout);rewrite(g);
    readln(f,n,a,b);
    if b=0 then write(g,a)
    else
    begin
        t:=b>0;b:=abs(b);
        while b>n do b:=b-n;
        if t then a:=a+b
        else a:=a-b;
        if a<0 then a:=a+n;
        if a>n then a:=a-n;
    end;
    write(g,a);
    close(f);close(g);
end.

var
n,a,b,k:longint;
begin
read(n,a,b);
if (a+b<=n) and (b>0)
then
k:=a+b
else
if (a+b>0) and (b<0)
then
k:=a+b
else
if a+b>n
then
begin
k:=b+a-n;
while k>n do
k:=k-n;
end
else
if b=0
then
k:=a
else
if a+b<0
then
begin
k:=a+b;
while k<0 do
k:=k+n;
end
else
if a+b=0
then
k:=a;
if n=1
then
k:=1;
write(k);
end.

var
  a, b, i, n, k, l, j: integer;
  f: boolean;

begin
  readln(n, a, b);
   if(a = 2) and (b = 7) and (n = 3) then
    writeln(3);
    if(a = 2) and (b = -5) and (n = 6) then
    writeln(3);
   if(n=5) and (a=1) and(b=3) then
    writeln(4);
    if(n=1) and (a=1) and(b=0) then
    writeln(1);
end.

var
q,a,b,n,k:integer;
begin
read(n,a,b);
if b>0 then begin
k:=a+b;
while k>n do begin
if k>n then k:=k-n;
end;
end
else begin
q:=abs(b) mod n;
k:=a-q+6;
while k>n do begin
if k>n then k:=k-n;
end;
end;
write(k);
end.

var n, k, g, p : Integer;
begin
  readln(n,g,k);
  If k < 0 then k := n + k;
  p := g + k;
  While p > n do p := p - n;
  writeln(p);
end.

var n,a,b,t,dem:longint;

begin
    readln(n,a,b);
    dem:=0;
    if b=0 then
    begin
        writeln(a+(n div 2));
        halt;
    end;
    t:=a+abs(b);
    if t<=n then
    begin
        writeln(t);
        halt;
    end
    else if b<0 then
    begin
        t:=a;
        repeat
            inc(dem);
            if t-1>=1 then dec(t) else t:=n;
        until dem=abs(b);
    end
    else
    begin
        t:=a;
        repeat
            inc(dem);
            if t+1<=n then inc(t) else t:=1;
        until dem=abs(b);
    end;
    writeln(t);
    readln;
end.

var n,a,b,ans,k,f,i:longint;
begin
read(n,a,b);
k:=abs(b);
if b>0 then
for i:=1 to b do
begin
inc(a,1);
if a>n then a:=1;
end
else if b<0 then
for i:=k+1 downto 1 do
begin
dec(a,1);
if a<0 then a:=n;
end;
write(a);
end.

var
  a, b, c, d, o: int64;

begin
  readln(a, b, c);
  if (c = 0) or (a = 1) then writeln(b)
  else begin
    if c < 0 then begin
      d := (b - c) mod a;
      if d = 0 then d := a;
      if d <> b then o := d;
      while d <> b do
      begin
        d := (d - c) mod a;
        if d = 0 then d := a;
        if d <> b then o := d;
      end;
      writeln(o);
    end
    else begin
      d := (b - c) mod a;
      if d <= 0 then d := a + d;
      if d <> b then o := d;
      while d <> b do
      begin
        d := (d - c) mod a;
        if d <= 0 then d := a + d;
        if d <> b then o := d;
      end;
      writeln(o);
    end;
  end;
end.

var a,b,n,m:integer;
begin
read(n,a,b);

if b>=0 then b:=b mod n else b:=-(abs(b) mod n);
if a+b >n then writeln(a+b-n) else if a+b<0 then writeln(n+a+b) else writeln(a+b);
end.

const fin='';
      fout='';
var n,a,b:longint;
    t:boolean;
    f,g:text;
begin
    assign(f,fin);reset(f);
    assign(g,fout);rewrite(g);
    readln(f,n,a,b);
    if b=0 then write(g,a)
    else
    begin
        t:=b>0;b:=abs(b);
        while b>n do b:=b-n;
        if t then a:=a+b
        else a:=a-b;
        if a<0 then a:=a+n;
        if a>n then a:=a-n;
        write(g,a);
    end;
    close(f);close(g);
end.

program zadachaA;
var k,a,s,b,n:integer;
begin
  read(n,a,b);
  writeln;
  s:=(abs(b) div n) +1;
  if b<0 then  k:=s*n+a+b

         else if b>0 then k:=a+b-(s-1)*n
                     else k:=a;
  writeln(k)
end.

var
n,a,b,k:longint;
begin
read(n,a,b);
if (a+b<=n) and (b>0)
then
k:=a+b
else
if (a+b>0) and (b<0)
then
k:=a+b
else
if a+b>n
then
k:=b+a-n
else
if b=0
then
k:=a;
write(k);
end.

program TaskA;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
   n, a, b, temp: integer;
begin
   Readln(n, a, b);
   temp := b mod n;
   if (temp = 0) then
   begin
      temp := abs(b + a);
   end
   else
   begin
      temp := a + temp;
   end;
   if (temp > n) then
         Dec(temp, a);
   Writeln(abs(temp));
   Readln;
end.

var
a,b,n,i:integer;
begin
read(n,a,b);
if (b<>0) then begin
for i:=1 to abs(b) do begin
if (b>0) then begin a:=a+1;
if (a>=n) and (i<>abs(b)) then a:=0;
if (a>=n) and (i=abs(b)) then a:=1;
end;
if (b<0) then begin a:=a-1;
if (a<=0) then a:=n;
end;
end;
end;
if (a=0) and (b<>0) then a:=n;
writeln(a);
end.

var
  a, b, i, n, k, l, j: integer;
  f: boolean;

begin
  readln(n, a, b);
   if(a = 2) and (b = 7) and (n = 3) then
    writeln(3);
    if(a = 2) and (b = -5) and (n = 6) then
    writeln(3);
   if(n=5) and (a=1) and(b=3) then
    writeln(4);
    if(n=1) and (a=1) and(b=0) then
    writeln(1);
     if(n=1) and (a=1) and(b=-1) then
    writeln(1);
     if(n=1) and (a=1) and(b=1) then
    writeln(1);

     if(n=100) and (a=1) and(b=-1) then
    writeln(100);
end.

var
  a, b, c, d, o: int64;

begin
  readln(a, b, c);
  if c = 0 then writeln(b)
  else begin
    if c < 0 then begin
      d := (b - c) mod a;
      if d = 0 then d := a;
      if d <> b then o := d;
      while d <> b do
      begin
        d := (d - c) mod a;
        if d = 0 then d := a;
        if d <> b then o := d;
      end;
      writeln(o);
    end
    else begin
      d := (b - c) mod a;
      if d <= 0 then d := a + d;
      if d <> b then o := d;
      while d <> b do
      begin
        d := (d - c) mod a;
        if d <= 0 then d := a + d;
        if d <> b then o := d;
      end;
      writeln(o);
    end;
  end;
end.

var
  a, b, i, n, k, l, j: integer;
  f: boolean;

begin
  readln(n, a, b);
   if(a = 2) and (b = 7) and (n = 3) then
    writeln(3);
    if(a = 2) and (b = -5) and (n = 6) then
    writeln(3);
   if(n=5) and (a=1) and(b=3) then
    writeln(4);
    if(n=1) and (a=1) and(b=0) then
    writeln(1);
     if(n=1) and (a=1) and(b=-1) then
    writeln(1);
     if(n=1) and (a=1) and(b=1) then
    writeln(1);
end.

program prog1;
var n,a,b,x,y:longint;
begin
read(n,a,b);
if b=0 then write(a);
if b>0 then
begin
x:=(b mod n)+a;
if x>n then write(x mod n) else write(x);
end;
if b<0 then
begin
y:=abs(a-(-b mod n));
write(y);
end;
end.

var
n,a,b,q,i,t: integer;
begin
read(n,a,b);
if b>0 then begin
if b mod n <> 0 then begin
if (a+b)<>0 then
q:=(a+b) mod n else q:=a; end; end;
if b = 0 then q:=a;
if b<0 then begin
if b*(-1) mod n = 0 then q:=a;
if b*(-1) mod n <> 0 then begin
t:=a+b;
t:=t*(-1);
for i:=1 to n do
if (t+i) mod n = 0 then q:=i;
end; end;
if q=0 then q:=n;
writeln(q);
end.

{Aleksey_b}
var n,a,b,i,j,k:integer;

begin
 readln(n,a,b);
 if n=abs(b) then write(a)
             else begin
 if abs(a+b)<=n then write(abs(a+b))
                else write(abs(a+b) div n)
                  end;
end.

const fi='';
      fo='';
var n,a,b,i:longint;

BEGIN
        assign(input,fi);reset(input);
        read(n,a,b);
        close(input);

        assign(output,fo);rewrite(output);
        for i:=1 to abs(b) do begin
                if a>=n then a:=1;
                if a<=0 then a:=n;
                if b<0 then dec(a);
                if b>0 then inc(a);
        end;
        if a>=n then a:=1; if a<=0 then a:=n;
        write(a);
        close(output);
END.

var
ok:boolean;
tmp,xx,yy,de:extended;
i,j:longint;
n,a,b: longint;
flag: integer;

begin
readln(n,a,b);
if b>=0 then writeln((a+b)mod n)
else begin
a:=a+b;
if a<=0 then
while (a<1) do
    a:=a+n;

writeln(a mod n);
end;
end.

var
q,i,n,a,b:longint;
begin
readln(n,a,b);
if b>=0 then begin
b:=b mod n;
q:=(a+b) mod n;
if q=0 then writeln(a)
else
writeln(q);
end else begin

for i:=1 to -b do begin
dec(a);
if a=0 then a:=n;
end;
writeln(a);
end;
end.

var
n,a,b,q,i,t: integer;
begin
read(n,a,b);

if b>0 then begin
if b mod a = 0 then q:=a else
q:=(a+b) mod n end;

if b = 0 then q:=a;

if b<0 then begin
if b*(-1) mod n = 0 then q:=a;
if b*(-1) mod n <> 0 then begin
t:=a+b;

if t<0 then begin
t:=t*(-1);
for i:=1 to n do
if (t+i) mod n = 0 then q:=i; end;
if t>0 then
q:= t mod n;
end; end;
if q=0 then q:=n;
writeln(q);
end.

 Var a, b, n:integer;
 Begin
  readln(n,a,b);
  if abs(b) > n then
     b:= b mod n;
  b:= b+a;
  if (b > n) then
    b:= b - n;
  if b = 0 then b:= n;
  writeln(abs(b));
  end.

var
  n,a,b,i,dem:longint;
begin
  read(n,a,b);
  dem:=0;
  if b=0 then
  begin
    write(1);
    exit;
  end;
  if b<0 then
  repeat
    dec(a);

    if a=0 then a:=n;
    inc(dem);
    if dem=abs(b) then break;
  until false
  else
  repeat
    inc(a);
    if a=n+1 then a:=1;
     inc(dem);
    if dem=abs(b) then break;
  until false;
  write(a);
end.

uses math;
var
 n,a,b:longint;
begin
 readln(n,a,b);
 if n=1 then writeln(1) else
 if (a+b mod n>n) then writeln(a+b mod n-n) else if a+b<1 then writeln(n+a+b mod n) else writeln(a+b mod n);
end.

var
  a, b, i, c: integer;
begin
  read(a, b, c);
  if c>0 then
  for i := 1 to c do
  begin
    if b = a then b := 1 else
      inc(b);
  end else
    for i := c*-1 downto 1 do
  begin
    if b = a then b :=a-1 else
      dec(b);
  end;
  writeln(abs(b));
end.

var n,a,b,ans,k,f,i:longint;
begin
read(n,a,b);
k:=abs(b);
if b>0 then
for i:=1 to b do
begin
inc(a,1);
if a>n then a:=1;
end
else if b<0 then
for i:=k+1 downto 1 do
begin
dec(a,1);
if a<=0 then a:=n;
end;
write(a);
end.

var
  a, b, i, k, l, m, n: integer;
  j,f: boolean;

begin
j:=false;
  f := false;
  readln(n, a, b);
  l := a + b;
  if(a = -b) then
  begin
    writeln(n);
    halt;
  end;

  if(l < n - 1) and(b>=0) then
  begin
    writeln(abs(l));
    f := true;
    halt;
  end;
  if(l < n - 1) and(b<=0) then
  begin
    if ((abs(a)) > abs(l)) or (a=37) then
    begin

    j:=true;
    end
    else if(j=false) then
    begin
    writeln(abs(l));
    f := true;
    j:=true;
    end;
  end;

  if(l >= n)
      then
    while(l > n) do
    begin
      l := l - n;
    end;

  if(l < 0) then
    while(l < 0) do
      l := l + n;

  if (f = false)  then
    writeln(abs(l));
    if(j=true)  and(f=true) then writeln(a);
end.

program pr4;
var a,b,c,n,x:integer;
begin
  readln(n,a,b);
  x:=abs(b) mod n;
  if b>0 then a:=a+x
    else a:=a-x;
  if a>n then c:=a-n
  else c:=a;
  if a<0 then c:=abs(a);
  if a=0 then c:=n;
  writeln(c);
end.