program
HelloWorld;
var n:array
[1..1000] of integer;
var mx, mn,
res: integer;
var i:
SmallInt;
begin
//заполняем массив
for i:=1 to 100 do
n[i] := random(1000);
mx := 0;
mn := 0;
for i:=1 to 100 do
begin
if(i mod 2 = 0) and (mx < n[i]) then mx
:= n[i];
if(i mod 3 = 0) and (mn > n[i]) then mn
:= n[i];
end;
res := mx+mn;
write(res);
end.