begin
var N, A, B, C, D: integer;
Readln(N, A, B, C, D);
if A > C then (A, B, C, D) := (C, D, B, A);
var s := 1.To(A - 1);
if B < C then // ( ) [ ]
s := s + B.Downto(A) + (B + 1).To(C - 1) +
D.Downto(C) + (D + 1).To(N)
else
if D < B then // ( [ ] )
s := s + SeqGen(C - A, t -> B - t) +
SeqGen(D - C + 1, t -> t + A + B - D) +
SeqGen(B - D, t -> A - t + B - D - 1) + (B + 1).To(N)
end
else // ( [ ) ]
SeqGen(D - B, t -> D - t) + SeqGen(B - C + 1, t -> A + t) +
(D + 1).To(N);
end;
s.Println;
end.
var a,b,c:array[1..100] of integer;
i,n:integer; z:real;
n:=random(10)+90;
writeln('n=',n);
writeln('array a=');
for i:=1 to n do
a[i]:=random(300);
z:=z+a[i];
write(a[i],' ');
if (i mod 10 =0) then writeln;
writeln;
write('Среднее арифметическое элементов массива=',z/n); writeln;
writeln('array b=');
if (i mod 3 = 0) then b[i]:=0 else b[i]:=a[i];
write(b[i],' ');
end; writeln; writeln('array a + array b=');
c[i]:=a[i]+b[i];
write(c[i],' ');
begin
var N, A, B, C, D: integer;
Readln(N, A, B, C, D);
if A > C then (A, B, C, D) := (C, D, B, A);
var s := 1.To(A - 1);
if B < C then // ( ) [ ]
s := s + B.Downto(A) + (B + 1).To(C - 1) +
D.Downto(C) + (D + 1).To(N)
else
if D < B then // ( [ ] )
begin
s := s + SeqGen(C - A, t -> B - t) +
SeqGen(D - C + 1, t -> t + A + B - D) +
SeqGen(B - D, t -> A - t + B - D - 1) + (B + 1).To(N)
end
else // ( [ ) ]
begin
s := s + SeqGen(C - A, t -> B - t) +
SeqGen(D - B, t -> D - t) + SeqGen(B - C + 1, t -> A + t) +
(D + 1).To(N);
end;
s.Println;
end.
var a,b,c:array[1..100] of integer;
i,n:integer; z:real;
begin
n:=random(10)+90;
writeln('n=',n);
writeln('array a=');
for i:=1 to n do
begin
a[i]:=random(300);
z:=z+a[i];
write(a[i],' ');
if (i mod 10 =0) then writeln;
end;
writeln;
write('Среднее арифметическое элементов массива=',z/n); writeln;
writeln('array b=');
for i:=1 to n do
begin
if (i mod 3 = 0) then b[i]:=0 else b[i]:=a[i];
write(b[i],' ');
if (i mod 10 =0) then writeln;
end; writeln; writeln('array a + array b=');
for i:=1 to n do
begin
c[i]:=a[i]+b[i];
write(c[i],' ');
if (i mod 10 =0) then writeln;
end;
end.