{
TASK: JTELE
LANG: PASCAL
}

program jtele;
  const inpFile = 'NULIS.IN';
        outFile = 'NULIS.OUT';
  var f: text;
      n, m, dabar, kitas: integer;
      pirmyn, atgal: integer;
      i, p, a: integer;

begin
  assign(f, inpFile);
  reset(f);
  readln(f, n, m, dabar);

  pirmyn := 0;
  atgal := 0;
  for i := 1 to m do
    begin
      readln(f, kitas);

      p := (n - dabar + kitas) mod n;
      a := (n - kitas + dabar) mod n;

      if p < a
        then pirmyn := pirmyn + p
        else atgal := atgal + a;

	writeln(p, ' ', a);

      dabar := kitas;
    end;

  close(f);

  assign(f, outFile);
  rewrite(f);
  writeln(f, pirmyn, ' ', atgal);
  close(f);
end.
