const undefined_value = 10001; var i, a, min_odd_a : Integer; n, sum, count_odd : LongInt; begin sum := 0; count_odd := 0; min_odd_a := undefined_value; ReadLn(n); for i:=1 to n do begin Read(a); if (a and 1) = 1 then begin inc(count_odd); if (a < min_odd_a) then begin min_odd_a:=a; end; end; sum := sum + a; end; if (count_odd > 0) and (count_odd and 1 = 1) then begin sum := sum - min_odd_a; end; if (sum = 0) then begin WriteLn('NIESTETY'); end else begin WriteLn(sum); end; ReadLn; end.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | const undefined_value = 10001; var i, a, min_odd_a : Integer; n, sum, count_odd : LongInt; begin sum := 0; count_odd := 0; min_odd_a := undefined_value; ReadLn(n); for i:=1 to n do begin Read(a); if (a and 1) = 1 then begin inc(count_odd); if (a < min_odd_a) then begin min_odd_a:=a; end; end; sum := sum + a; end; if (count_odd > 0) and (count_odd and 1 = 1) then begin sum := sum - min_odd_a; end; if (sum = 0) then begin WriteLn('NIESTETY'); end else begin WriteLn(sum); end; ReadLn; end. |