SlepoiKrot

Untitled

Dec 29th, 2017
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program massiv;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7.  
  8. var
  9.   n, a, k, j, i, sum: integer;
  10. begin
  11.   k := 0;
  12.   j := 0;
  13.   sum := 0;
  14.   readln (n);
  15.   for i := 1 to n do begin
  16.     readln (a);
  17.     if (a mod 3 = 1) then begin
  18.       inc (sum);
  19.       inc (k);
  20.     end;
  21.     if (a mod 3 = 2) then begin
  22.       inc (sum, 2);
  23.       inc (j);
  24.     end;
  25.   end;
  26.   if (sum mod 3 = 1) then
  27.     if (k >= 1) then
  28.       writeln (n - 1)
  29.     else
  30.       writeln (n - 2);
  31.   if (sum mod 3 = 2) then
  32.     if (j >= 1) then
  33.       writeln (n - 1)
  34.     else
  35.       writeln (n - 2);
  36.   if (sum mod 3 = 0) then
  37.     writeln (n);
  38.   readln;
  39.   readln;
  40. end.
RAW Paste Data