简单题,普通hash即可

program count;
type
  node=record
    num,t:longint;
  end;
var
  hash:array[1..1000000] of node;
  a:array[1..10000] of node;
  n,i,data,p,len:longint;
  flag:boolean;
procedure quick(left,right:longint);
var
  i,j,temp:longint;
  x:node;
begin
  i:=left;
  j:=right;
  temp:=a[(i+j) div 2].num;
  while i<=j do
  begin
    while a[i].num<temp do inc(i);
    while a[j].num>temp do dec(j);
    if i<=j then
    begin
      x:=a[i];
      a[i]:=a[j];
      a[j]:=x;
      inc(i);
      dec(j);
    end;
  end;
  if left<j then quick(left,j);
  if i<right then quick(i,right);
end;
begin
  assign(input,'count.in');
  reset(input);
  assign(output,'count.out');
  rewrite(output);
  fillchar(hash,sizeof(hash),0);
  fillchar(a,sizeof(a),0);
  len:=0;
  readln(n);
  for i:=1 to n do
  begin
    readln(data);
    p:=data mod 1000000;
    if hash[p].num=0 then
    begin
      hash[p].num:=data;
      hash[p].t:=1;
      inc(len);
      a[len].num:=data;
      a[len].t:=p;
    end
    else
    begin
      flag:=true;
      while hash[p].num<>0 do
      begin
        if hash[p].num=data then
        begin
          inc(hash[p].t);
          flag:=false;
          break;
        end;
        inc(p);
      end;
      if flag then
      begin
        hash[p].num:=data;
        hash[p].t:=1;
        inc(len);
        a[len].num:=data;
        a[len].t:=p;
      end;
    end;
  end;
  quick(1,len);
  for i:=1 to len do
    writeln(a[i].num,' ',hash[a[i].t].t);
  close(input);
  close(output);
end.