{
TASK:AKMENUKAI
LANG:PASCAL
}
program penkiazenkliai;
  { 15 olimpiada, I etapas, Vyresniøjø grupë, 285 uþdavinys }
  const PRAD = 'akmuo.dat';
        REZ = 'akmuo.rez';
        MAX = 10; { maksimalus vaikø skaièius }
  type lentele = array [1..MAX] of integer;

  procedure dalinti (n: integer; var v: lentele);
    var i, kam, d: integer;
  begin
    for i := 1 to n-1 do { dalina i-asis vaikas }
      begin
        kam := i+1; d := 1;
       while (v[i] > 0) and (kam <> i) do
         begin
           v[kam] := v[kam] + 1;
           v[i] := v[i] - 1;
           if (kam = n) and (d = 1) { apsisukama }
              then d := -1
              else kam := kam + d;
         end;
      end;
  end; { dalinti }

  procedure skaityti (var n: integer; var v: lentele);
    var f: text;
        i: integer;
  begin
    assign (f, PRAD);
    reset (f);
    readln (f, n);
    for i := 1 to n do
     read(f, v[i]);
    close (f);
  end; { skaityti }

  procedure rasyti (n: integer; v: lentele);
    var f: text;
        i: integer;
  begin
    assign (f, REZ);
    rewrite (f);
    for i := 1 to n do
      write (f, v[i], ' ');
    close (f);
  end; { ra6yti }

  var n: integer;
      v: lentele;
begin
  skaityti (n, v);
  dalinti (n, v);
  rasyti (n, v);
end.
