program ideone;
Const smax = 99;
Type simple = array[0..smax] of smallint;
Var data, sort:simple; i, n, indMax1, indMax2, indMin1, indMin2:smallint;
procedure writeArr(data:simple);
Var i:smallint;
begin
for i:=0 to n-1 do write(data[i], ' ');
writeln();
end;
function bubbleSort(data:simple):simple;
Var i, j, t:smallint;
begin
for i:=0 to n-1 do
for j:=0 to n-2 do
if data[j]>data[j+1] then begin
t:=data[j];
data[j]:=data[j+1];
data[j+1]:=t;
end;
bubbleSort:=data;
end;
function getIndex(arr:simple; num:smallint):smallint;
Var i:smallint;
begin
i:=0;
while (arr[i]<>num) and (i<n) do i:=i+1;
getIndex:=i;
end;
procedure distance(data, sort:simple);
Var i, j, indMaxS1, indMaxS2:smallint;
begin
indMaxS1:=0;
indMaxS2:=1;
for i:=0 to n-2 do begin
for j:=i+1 to n-1 do
if abs(data[i]-data[j])<abs(data[indMin1]-data[indMin2]) then begin
indMin1:=i;
indMin2:=j;
end;
if abs(sort[i]-sort[i+1])>abs(sort[indMaxS1]-sort[indMaxS2]) then begin
indMaxS1:=i;
indMaxS2:=i+1;
end;
end;
indMax1:=getIndex(data, sort[indMaxS1]);
indMax2:=getIndex(data, sort[indMaxS2]);
end;
begin
indMax1:=0;
indMax2:=1;
indMin1:=0;
indMin2:=1;
read(n);
for i:=0 to n-1 do read(data[i]);
sort:=bubbleSort(data);
distance(data, sort);
writeln(abs(data[indMin1]-data[indMin2]), ' ', indMin1+1, ' ', indMin2+1);
writeln(abs(data[indMax1]-data[indMax2]), ' ', indMax1+1, ' ', indMax2+1);
end.
cHJvZ3JhbSBpZGVvbmU7CgpDb25zdCBzbWF4ID0gOTk7ClR5cGUgc2ltcGxlID0gYXJyYXlbMC4uc21heF0gb2Ygc21hbGxpbnQ7ClZhciBkYXRhLCBzb3J0OnNpbXBsZTsgaSwgbiwgaW5kTWF4MSwgaW5kTWF4MiwgaW5kTWluMSwgaW5kTWluMjpzbWFsbGludDsKCnByb2NlZHVyZSB3cml0ZUFycihkYXRhOnNpb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