var aa: array[1..1000] of longint; n, i, a, sum: longint; begin for i:=1 to 1000 do aa[i]:=0; sum:=0; readln(n); for i:=1 to n do begin read(a); inc(aa[a]); inc(sum, a); end; readln; if sum mod 2 <> 0 then begin i:=1; while (aa[i]=0) or (i mod 2 = 0) do inc(i); sum:= sum - i; end; if sum > 0 then writeln(sum) else writeln('NIESTETY'); end.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | var aa: array[1..1000] of longint; n, i, a, sum: longint; begin for i:=1 to 1000 do aa[i]:=0; sum:=0; readln(n); for i:=1 to n do begin read(a); inc(aa[a]); inc(sum, a); end; readln; if sum mod 2 <> 0 then begin i:=1; while (aa[i]=0) or (i mod 2 = 0) do inc(i); sum:= sum - i; end; if sum > 0 then writeln(sum) else writeln('NIESTETY'); end. |