uses crt;
const nmax=100;
var a:array[1..nmax] of word;
s,c:string;
n,i,j,k:word;
begin
clrscr;
repeat
write('Vvedite kolichestvo stranic n=');
readln(n);
until (n>1)and(n<=nmax);
repeat
writeln('Vvedite ',n,' nomerov stranic po vozrastaniyu:');
for i:=1 to n do
read(a[i]);
readln;
k:=0;
for i:=2 to n do
if a[i]<=a[i-1] then
begin
k:=1;
break;
end;
if k=1 then writeln('Dopushena oshibka! Povtorite vvod.');
until k=0;
str(a[1],c);
s:=c;
i:=2;
while i<=n do
begin
str(a[i],c);
if a[i]-a[i-1]<>1 then s:=s+', '+c;
if (a[i]-a[i-1]=1)and(a[i+1]-a[i]<>1) then s:=s+'-'+c;
if (a[i]-a[i-1]=1)and(a[i+1]-a[i]=1) then
begin
s:=s+'-';
inc(i);
end
else inc(i);
end;
for i:=length(s)downto 1 do
if (s[i]='-')and(s[i+1]=',') then
delete(s,i+1,2);
while pos('--',s)>0 do
delete(s,pos('--',s),1);
write(s);
readln
end.