Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:  start the race from some point of a field,  go around the flag,  close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of the point where the flag is situated (x2, y2). Polycarp’s quadcopter can fly only parallel to the sides of the field each tick changing exactly one coordinate by 1. It means that in one tick the quadcopter can fly from the point (x, y) to any of four points: (x - 1, y), (x + 1, y), (x, y - 1) or (x, y + 1).Thus the quadcopter path is a closed cycle starting and finishing in (x1, y1) and containing the point (x2, y2) strictly inside.    The picture corresponds to the first example: the starting (and finishing) point is in (1, 5) and the flag is in (5, 2). What is the minimal length of the quadcopter path?

The first line contains two integer numbers x1 and y1 ( - 100 ≤ x1, y1 ≤ 100) — coordinates of the quadcopter starting (and finishing) point. The second line contains two integer numbers x2 and y2 ( - 100 ≤ x2, y2 ≤ 100) — coordinates of the flag. It is guaranteed that the quadcopter starting point and the flag do not coincide.

Print the length of minimal path of the quadcopter to surround the flag and return back.

program Ann;
label l1;
var x1,x2,y2,y1,s,n,m:integer;
begin
readln(x1,y1);
readln(x2,y2);
if(x1 = x2)then
      begin
      s:=4+(abs(y1 - y2)+1)*2;
      goto l1;
      end;
if(y1 = y2)then
      begin
      s:=4 + (abs(x1 - x2)+1)*2;
      goto l1;
      end;
s:=(abs(y1 - y2)+ 1)*2 + (abs(x1 - x2)+1)* 2;
l1:
writeln(s);
end.

 var x1,x2,y1,y2:longint;
begin
read (x1,y1,x2,y2 );

 if x1=x2 then x1:=2 else x1:=abs(x1-x2)+1;
if  y1=y2 then y1:=2 else y1:=abs(y1-y2)+1;
write(2*(x1+y1));
end.

var
  nx, ny, x2, y2, x1, y1: integer;

begin
  readln(x1, y1);
  readln(x2, y2);
  if(x1 <> x2) and (y1 <> y2) then begin
    if(x1 > x2) then
      if(y1 > y2) then
      begin
        y2 := y2 - 1;x2 := x2 - 1;
      end else
      begin
        x2 := x2 - 1;y2 := y2 + 1;
      end
    else
    if(y1 > y2) then
    begin
      y2 := y2 - 1;x2 := x2 + 1;
    end else
    begin
      y2 := y2 + 1;x2 := x2 + 1;
    end;
    nx := abs(x1 - x2);ny := abs(y1 - y2);
    writeln((nx + ny) * 2);
  end else begin
    if(x1 = x2) then writeln(abs(y1 - y2)*2 + 6) else writeln(abs(x1 - x2)*2 + 6);
  end;
end.

var
  nx, ny, x2, y2, x1, y1 : integer;

begin
  readln(x1, y1);
  readln(x2, y2);
  if(x1 <> x2) and (y1 <> y2) then begin
    if(x1 > x2) then
      if(y1 > y2) then
      begin
        y2 := y2 - 1;x2 := x2 - 1;
      end else
      begin
        x2 := x2 - 1;y2 := y2 + 1;
      end
    else
    if(y1 > y2) then
    begin
      y2 := y2 - 1;x2 := x2 + 1;
    end else
    begin
      y2 := y2 + 1;x2 := x2 + 1;
    end;
    nx := abs(x1 - x2);ny := abs(y1 - y2);
    writeln((nx + ny) * 2);
  end else begin
    if(x1 = x2) then writeln(abs(y1 - y2)*2 + 6) else writeln(abs(x1 - x2)*2 + 6);
  end;
end.

program p1;
var
x1,x2,y1,y2,s:longint;
begin
     readln(x1,y1);
     readln(x2,y2);
     if (x1=x2) and (y1=y2) then
        s:=0 else
     if (x1=x2) then
        s:=2*(abs(x2-x1)+1)+2*(abs(y2-y1)+2) else
     if (y1=y2) then
        s:=2*(abs(x2-x1)+2)+2*(abs(y2-y1)+1) else
        s:=2*(abs(x2-x1)+1)+2*(abs(y2-y1)+1);
     writeln(s);
end.

var x1,y1,x2,y2,p:integer;
begin
p:=0;
readln(x1,y1);
readln(x2,y2);
if (abs(x1-x2)>1) and (abs(y1-y2)>1) then begin
p:=(abs(x1-x2)+1+abs(y1-y2)+1)*2;
writeln(p);
end else
if (abs(x1-x2)>1) and (abs(y1-y2)<=1) then begin
p:=(2+abs(x1-x2)+1)*2; writeln(p);
end else
if (abs(x1-x2)<=1) and (abs(y1-y2)>1) then begin
p:=(2+abs(y1-y2)+1)*2;
writeln(p);
end else
if p=0 then writeln(8);

end. //idinafig

                      const eps=0.0000000001;  besk1=200000008;  nnn=4600000;
            besk=80000000000000000;
              modul={1000000007}{998244353}100;

   label 22,1,2,3,4,33;
    type    real=extended;   double=extended;
    mas=array [-300000..nnn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;
    mass=array[-10000..nnn] of longint;mass1=^mass;
    matr=array[-10..200,-10..200] of int64;
    matr1=^matr;
    var oldq,ll,rr,maskk,otmin,otmax,izb,kol,oldpp,t,pos1,pos2,r,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,cc,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,nm,smin,cen:int64;
   istart,jstart,ifinish,jfinish,k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;
   zagr,xx,yy,kolizm,test,zz,predok,hesh,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;
    otmat,amat,bmat,cmat:matr;
    zan1,zan2:array[-1000..200000,-2..26] of boolean;
    marked1,marked2:array[-2000..2000000] of boolean;
   gr1,gr2,gr:array[-1..2000,-1..2000] of boolean;
    dd,ddr:array[-1..1502,-1..1502] of int64;
    prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;
    iii,oldpos,finot,vv,znak:int64;
    aold:mas;  anss:zap;
    sss,ss,ss1,ss2:string;
    newstr,str:array[-1000..200000] of string;
    lll,rrr,v,dist,alpha,phi:extended;
    masmatr:array[-1..101,-1..101,-1..101] of int64;
    zzz,ddnew,koef,polex,ddsum,ddl:array[-1..4,-1..1300000] of int64;
    str1,str2,dpos,sum,ppos,mma,ma:array[-1000..200005,-1..30] of int64;
    xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;
    del:array[-1..100001,-1..20] of longint;
    z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;
    zzzz:array[0..125000000] of byte;
    aaaa,bbbb,x2:extended;
    delit:array[0..100000,0..20] of longint;
    pole:array[-10..2002,-10..2005] of char;
    ddd,matrr,ppole,dd3,dd4:array[-10..2000,-10..2200] of int64;
    ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;
   newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;
    ssold,sss1,sss2:string;
    def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;
     zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;
     dost:array[-1..210,-1..210,0..3,0..3] of int64;
    sss12:string;ch,ch1,ch2:char;
    pr,heshh,numright,dr: array [-10..206,-1..16] of int64;
    s3,s2,s1:array[-100..500000] of string;

    grr :array [-10..2010,-10..2010] of extended;
    maxpr:array[0..nnn] of string;
     tx,ty,vel,ott,v0,v1,s0,t0:int64;
     zv:point;
     left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;
     mash,sqx,sqy,ottt:extended;
     xxxx,yyyy,yot:double;
       flag2,flag,flag1:boolean;

  function max(a,b:int64):int64;
begin max:=a; if b>a then max:=b;   end;

  function min(a,b:int64):int64;
begin min:=a; if b<a then min:=b;   end;

procedure udal(p:longint);
begin  next[prev[p]]:=next[p]; prev[next[p]]:=prev[p]; end;

      function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

     function summ(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=t1 div tt mod modul;
    t2:=t2 div tt mod modul;
    ott.p1:=t1; ott.p2:=t2;

   summ:=@ott;
 end;

     function prod(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=(t1 div tt) mod modul;
    t2:=(t2 div tt) mod modul;
    ott.p1:=t1; ott.p2:=t2;

   prod:=@ott;
 end;

    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p{/pi*180};
 end;

function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k shr 1); degg:=p*p mod modul;   end;

end;

function prost(tt:int64):boolean;
var aa:extended; i,p,t:longint;  fl:boolean;
 begin
   fl:=true;
   aa:=tt;
   aa:=sqrt(aa);
   t:=round(aa);
   for i:=2 to t do if tt mod i=0 then begin fl:=false; break; end;

   prost:=fl;
 end;

function arcsin(pp:extended):extended;
var tt:extended;
begin
   if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)
   then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;
   tt:=1-pp*pp;
   if abs(tt)>=0 then
     begin
        arcsin:=arctan(pp/sqrt(tt));

     end;

end;

function gl(ch:char):boolean;
begin
 if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;

end;

function zaprmin(left,right:longint):int64;
begin
   if left>=right then zaprmin:=y[left] else
     begin
        if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else
         begin
          if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);
          if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);

         end;

     end;

end;

 function ff(gr:int64):boolean;

var ot,aa,bb,cc:int64; fl:boolean;
begin
  aa:=1; bb:=m;  cc:=aa; fl:=false;
  while abs(aa-bb)>1 do
    begin
       cc:=(aa+bb) shr 1;
       if y[cc]<gr then aa:=cc else bb:=cc;

    end;
   writeln(' cc= ',cc);
   cc:=min(cc+3,m+1);
   repeat dec(cc) until y[cc]<=gr;
   if y[cc]=gr then fl:=true else fl:=false;
  ff:=fl;
end;

function prodc(t:int64):int64;
var i,j,k:longint; p,ot:int64;
begin
  k:=0;
  while (t>0) do begin inc(k); x[k]:=t mod 10; t:=t div 10; end;
  ot:=1;
  for i:=1 to k do ot:=ot*x[i];
 prodc:=ot;
end;

function koll(ost,modd,gr:int64):int64;
var ans,p1,p2,p,t,tt,ot:int64;
begin
 { writeln('gr= ',gr,' modd= ',modd,'  ost= ',ost,'  chisl= ',(gr+modd-ost));
 } p2:=(gr+modd-ost) div modd;
  koll:=p2;
end;

function est(ost,modd,ll,rr:int64):boolean;
var p1,p2,p,t,tt,ot:int64; ans:boolean;
begin
  est:=koll(ost,modd,rr)-koll(ost,modd,ll-1)>0

end;

begin
   { assign (input,'D:\Projects\input.txt');reset(input);
      assign (output,'D:\Projects\output.txt'); rewrite(output);
    }

     for i:=1 to 2 do read(x[i],y[i]);
     for i:=1 to 1 do ot:=ot+abs(x[i]-x[i+1])+abs(y[i]-y[i+1]);
     if (x[1]<>x[2])and(y[1]<>y[2]) then write(2*ot+4) else write(2*ot+6);

     goto 1;

     readln(p,t);
     q:=1;
     x[1]:=p;
     ll:=q;
     rr:=q;
     for step:=1 to 30 do
       begin
          for i:=ll to rr do if 2*x[i]<2000000000 then begin inc(q); x[q]:=2*x[i]; y[q]:=i;  end;
          for i:=ll to rr do if 10*x[i]+1<2000000000 then begin inc(q); x[q]:=10*x[i]+1; y[q]:=i; end;
          ll:=rr+1; rr:=q;

       end;

      writeln('q= ',q);
      for i:=1 to q do write(x[i],' '); writeln;

      for i:=1 to q do if x[i]=t then begin flag:=true; ii:=y[i];  end;
      if not flag then writeln('NO');

      while (y[ii]<>1)and(tt<100) do begin inc(tt); z[tt]:=y[ii]; ii:=y[ii];   end;

     writeln('tt= ',tt);
    { for i:=1 to tt do write(x[])
     }

1:             close(output);
end.

var
  ans,x1,y1,x2,y2:longint;
begin
  readln(x1,y1);
  readln(x2,y2);
  ans:=2*(abs(x1-x2)+abs(y1-y2)+2);
  if (x1=x2)or(y1=y2) then inc(ans,2);
  writeln(ans);
end.

VAR
  a, b, x, y, ans, w: LONGINT;
BEGIN
  READLN(a,b);
  READLN(x,y);
  IF x>a
  THEN
    BEGIN
      w := a;
      a := x;
      x := w;
    END;
  IF b<y
  THEN
    BEGIN
      w := b;
      b := y;
      y := w;
    END;
  ans := a+b-x-y+2;
  ans := ans*2;
  IF (a=x) OR (b=y)
  THEN
    ans := ans+2;
  IF (a=x) AND (b=y)
  THEN
    ans := 8;
  WRITELN(ans);
END.

var
        x1, x2, y1, y2 : longint;
begin
   readln( x1, y1 );
   readln( x2, y2 );
   if ( x1 <> x2 ) and ( y1 <> y2 )
      then
         begin
         writeln( ( abs( x1 - x2 ) + abs(y1 - y2) + 2 ) * 2 );
         end
      else
         begin
         writeln( ( abs( x1 - x2 ) + abs( y1 - y2 ) - 1 ) * 2 + 8 );
         end;
end.

var x1,x2,y1,y2,x,y:integer;
begin
readln(x1,y1);
readln(x2,y2);
x:=(abs(x1-x2)+abs(y1-y2)+2)*2;
y:=(abs(x1-x2)+abs(y1-y2)-1)*2+8;
   if (x1<>x2)and(y1<>y2)
      then writeln(x) else writeln(y);
end.

(* Enter your code here. Read input from STDIN. Print output to STDOUT *)
var
    x1,x2,y1,y2,h,l : longint;
begin
    read(x1,y1,x2,y2);
    if y1 > y2 + 1 then h := y1 - (y2 + 1)
    else if y1 < y2 - 1 then h := (y2 - 1) - y1
    else h := 0;
    if x1 > x2 + 1 then l := x1 - (x2 + 1)
    else if x1 < x2 - 1 then l := (x2 - 1) - x1
    else l := 0;
    write((l+h)*2 + 8);
end.

var     x1,x2,y1,y2:longint;

begin
        readln(x1,y1);
        readln(x2,y2);
        write(abs(x1-x2+1)+abs(y1-y2+1)+4+abs(x1-x2-1)+abs(y1-y2-1));
end.

var x, y, m, n, x1, y1:longint;
begin readln(x, y);
      readln(x1, y1);
      n:=abs(x1-x)+1;
      m:=abs(y1-y)+1;
      if x=x1 then inc(n);
      if y1=y then inc(m);
      writeln(2*(n+m));
end.

var x1,x2,y1,y2,i,k,x,y:integer;
begin
readln(x1,y1);
readln(x2,y2);
if (x1<>x2)and(y1<>y2)then begin
x:=abs(x1-x2)+1;
y:=abs(y1-y2)+1;
k:=x+y;
write(2*k);halt;end else
if x1=x2 then begin x:=2;y:=abs(y1-y2)+1;write(2*(x+y));halt;end else begin x:=abs(x1-x2)+1;y:=2;write(2*(x+y));halt;end;
end.

{$mode objfpc}

var
  x,y,u,v:integer;

begin
  read(x,y);
  read(u,v);
  if (x <> u) and (y <> v) then writeln(abs(x-u)*2+abs(y-v)*2+4)
  else writeln(abs(x-u)*2+abs(y-v)*2+6);
end.

var P, x,y,x1,y1,l,k:integer;
begin
read(x,y);read(x1,y1);
l:=abs(x1-x)+1;
k:=abs(y1-y)+1;
if x=x1 then l:=l + 1 ;
if y=y1 then k:=k+1;
P:=2*(k+l);
writeln(p);
end.

Program z1;
var x1,y1,x2,y2,k:integer;
begin
readln(x1,y1);
read(x2,y2);
if x1>x2 then k:=k+x1-x2+1;
if x1<x2 then k:=k+x2+1-x1;
if y1>y2 then k:=k+y1-y2+1;
if y2>y1 then k:=k+y2+1-y1;
if (x1=x2)or(y1=y2) then k:=k+2;
k:=k*2;
write(k);
end.

program Ann;
label l1;
var x1,x2,y2,y1,s,n,m:integer;
begin
readln(x1,y1);
readln(x2,y2);
if(x1 = x2)then
      begin
      s:=4+(abs(y1 - y2)+1)*2;
      goto l1;
      end;
if(y1 = y2)then
      begin
      s:=4 + (abs(x1 - x2)+1)+2;
      goto l1;
      end;
s:=(abs(y1 - y2)+ 1)*2 + (abs(x1 - x2)+1)* 2;
l1:
writeln(s);
end.

var
  nx, ny, x2, y2, x1, y1: integer;

begin
  readln(x1, y1);
  readln(x2, y2);
  if(x1 <> x2) and (y1 <> y2) then begin
    if(x1 > x2) then
      if(y1 > y2) then
      begin
        y2 := y2 - 1;x2 := x2 - 1;
      end else
      begin
        x2 := x2 - 1;y2 := y2 + 1;
      end
    else
    if(y1 > y2) then
    begin
      y2 := y2 - 1;x2 := x2 + 1;
    end else
    begin
      y2 := y2 + 1;x2 := x2 + 1;
    end;
    nx := abs(x1 - x2);ny := abs(y1 - y2);
    writeln((nx + ny) * 2);
  end else begin
    if(x1 = x2) then writeln(abs(y1 - y2) + 7) else writeln(abs(x1 - x2) + 7);
  end;
end.

var
  nx, ny, x2, y2, x1, y1: integer;

begin
  readln(x1, y1);
  readln(x2, y2);
  if(x1 <> x2) and (y1 <> y2) then begin
    if(x1 > x2) then
      if(y1 > y2) then
      begin
        y2 := y2 - 1;x2 := x2 - 1;
      end else
      begin
        x2 := x2 - 1;y2 := y2 + 1;
      end
    else
    if(y1 > y2) then
    begin
      y2 := y2 - 1;x2 := x2 + 1;
    end else
    begin
      y2 := y2 + 1;x2 := x2 + 1;
    end;
    nx := abs(x1 - x2);ny := abs(y1 - y2);
    writeln((nx + ny) * 2);
  end else begin
    if(x1 = x2) then writeln(abs(y1 - y2) + 8) else writeln(abs(x1 - x2) + 8);
  end;
end.

var x1,y1,x2,y2,p:integer;
begin
p:=0;
readln(x1,y1);
readln(x2,y2);
if (abs(x1-x1)<>1) and (abs(y1-y2)<>1) then begin
p:=(abs(x1-x2)+1+abs(y1-y2)+1)*2;
writeln(p);
end else
if p=0 then writeln(8);

end.

var x1,y1,x2,y2,p:integer;
begin
p:=0;
readln(x1,y1);
readln(x2,y2);
if (abs(x1-x2)>1) and (abs(y1-y2)>1) then begin
p:=(abs(x1-x2)+1+abs(y1-y2)+1)*2;
writeln(p);
end else
if p=0 then writeln(8);

end.

(* Enter your code here. Read input from STDIN. Print output to STDOUT *)
var x,y,i,j:longint;
begin
readln(x,y);
readln(i,j);

x:=abs(x-i);
y:=abs(y-j);

writeln((x+y)*2+4);
end.

var x1,x2,y1,y2,i,k,x,y:integer;
begin
readln(x1,y1);
readln(x2,y2);
if (x1<>x2)and(y1<>y2)then begin
x:=abs(x1-x2)+1;
y:=abs(y1-y2)+1;
k:=x+y;
write(2*k);halt;end else
if x1=x2 then begin x:=2;y:=abs(y1-y2)+1;write(2*(x+y));halt;end else begin x:=abs(x1-x2);y:=2;write(2*(x+y));halt;end;
end.

var P, x,y,x1,y1,l,k:integer;
begin
read(x,y);read(x1,y1);
l:=abs(x1-x);
k:=abs(y1-y);
if x=x1 then y:=y + 1 ;
if y=y1 then x:=x+1;
P:=2*(l+1)+2*(k+1);
writeln(p);
end.

var P, x,y,x1,y1,l,k:integer;
begin
read(x,y);read(x1,y1);
l:=abs(x1-x)+1;
k:=abs(y1-y)+1;
if x=x1 then l:=y + 1 ;
if y=y1 then k:=x+1;
P:=2*(k+l);
writeln(p);
end.

var P, x,y,x1,y1,l,k:integer;
begin
read(x,y);read(x1,y1);
if x=x1 then y:=y + 1 ;
if y=y1 then x:=x+1;
l:=abs(x1-x);
k:=abs(y1-y);
P:=2*(l+1)+2*(k+1);
writeln(p);
end.

var P, x,y,x1,y1,l,k:integer;
begin
read(x,y);read(x1,y1);
l:=abs(x1-x)+1;
k:=abs(y1-y)+1;
if x=x1 then y:=y + 1 ;
if y=y1 then x:=x+1;
P:=2*(k+l);
writeln(p);
end.


There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible.

The first line of the input contains integer n (2 ≤ n ≤ 100) — the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ 100), where ai is equal to the number written on the i-th card.

Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them.

NoteIn the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable.

 var a:array [1..2,1..100] of byte;
     n,i,j,k:byte;

 begin
 readln(n);
 for i:=1 to n do
  begin
   read(a[1,i]);
   a[2,i]:=i;
  end;
 for i:=1 to n-1 do
  for j:=i+1 to n do
   if a[1,i]>a[1,j] then
                     begin
                      k:=a[1,i]; a[1,i]:=a[1,j]; a[1,j]:=k; //swap(a[1,i],a[1,j]);
                      k:=a[2,i]; a[2,i]:=a[2,j]; a[2,j]:=k;//swap(a[2,i],a[2,j]);
                     end;
 for i:=1 to n div 2 do writeln(a[2,i],' ',a[2,n-i+1]);
 end.

var a, b :array [1..100] of longint;
    k, i, j, n : longint;
begin
    readln(n);
    for i := 1 to n do
        read(a[i]);
    for i := 1 to n do
        b[i] := i;
    for i := 1 to n do
        for j := 1 to n - 1 do
            if a[j] > a[j + 1] then begin
                k := a[j];
                a[j] := a[j + 1];
                a[j + 1] := k;
                k := b[j];
                b[j] := b[j +1];
                b[j + 1] := k;
            end;
    for i := 1 to n div 2 do
        writeln( b[i], ' ', b[n - i + 1]);
end.

var
	n, sum: integer;
	a: array of integer;

begin
	readln(n);
	SetLength(a, n);

	for var i := 0 to n - 1 do
	begin
		read(a[i]);
		sum += a[i];
	end;
	sum := sum div (n div 2);

	for var i := 0 to n - 1 do
		for var j := n - 1 downto 0 do
		begin
			if (a[i] + a[j] = sum) then
			begin
				write(j + 1);
				write(' ');
				writeln(i + 1);
				a[i] := 0;
				a[j] := 0;
				break;
			end;
		end;

end.

Var a,b:array [1..100] of longint;
    i,n:longint;
procedure qSort(l,r:longint);
  var i,j,z,x:longint;
begin
   i:=l;
   j:=r;
   x:=a[(i+j)div 2];
   repeat
        while a[i]<x do i:=i+1;
        while a[j]>x do j:=j-1;
        if i<=j then begin
                        z:=a[i];
                        a[i]:=a[j];
                        a[j]:=z;
                        z:=b[i];
                        b[i]:=b[j];
                        b[j]:=z;
                        i:=i+1;
                        j:=j-1;
                      end;
   until (i>j);
   if i<r then qSort(i,r);
   if j>l then qSort(l,j);
end;
 Begin
  read(n);
  for i:=1 to n do
   read(a[i]);
  for i:=1 to n do
   b[i]:=i;
  qSort(1,n);
  for i:=1 to n div 2 do
   writeln(b[i],' ',b[n-i+1]);
 End.

var n , i, j, sum, sum1 : longint;
    A : array [1..200] of longint;
begin
   readln(n);
   for i := 1 to n do
      read(A[i]);
   sum := 0;
   sum1 := 0;
   for i := 1 to n do
      sum := sum + A[i];
   sum := sum div (n div 2);
   for i := 1 to n do
      for j := 1 to n do
         if (A[i] + A[j] = sum) and (i <> j) then
         begin
            writeln(i,' ', j);
            A[i] := 200;
            A[j] := 200;
            break;
         end;
end.

var
 a,b,c,d,n,m,p,i,i2,i4:integer;
 q:array[1..100] of integer;
 w:array[1..100] of integer;
 s:string;
Begin
 readln(p);
 m:=999;
 n:=0;
 for i:=1 to p do begin
 read(q[i]);
 if n<q[i] then n:=q[i];
 if m>q[i] then m:=q[i];
 end;

 for i:=1 to p do
 for i2:=1 to p do
  if ((n+m)-(q[i]+q[i2])=0) and (i<>i2) and (q[i]<>0) and (q[i2]<>0) then begin
   writeln(i,' ',i2);
   q[i]:=0;
   q[i2]:=0;
  end;
end.

var n,i,tong,tam,j:longint;
                a:array[1..100]of integer;
                dd:array[1..100]of byte;
begin
        readln(n);
        for i:=1 to n do
        begin
        read(a[i]);
        tong:=tong+a[i];
        end;
        tam:=tong div (n div 2);
        for i:=1 to n-1 do
        for j:=i+1 to n do
        if (a[i] + a[j] = tam) and (dd[i] = 0) and (dd[j] = 0) then
        begin
        writeln(i,' ',j);
        dd[i]:=1;
        dd[j]:=1;
        break;
        end;
        readln;
end.

var n, i, j, x, y:integer;
    a, b:array [1..10000] of longint;
begin
 read(n);
 for i:=1 to n do begin
  read(a[i]);
  b[i]:=i;
 end;
 for i:=1 to n-1 do
  for j:=i+1 to n do
   if a[i]>a[j] then begin
    x:=a[i]; a[i]:=a[j]; a[j]:=x;
    y:=b[i]; b[i]:=b[j]; b[j]:=y;
   end;
 for i:=1 to n div 2 do
  writeln(b[i],' ',b[n-i+1]);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
type m=array [1..100,1..2] of longint;
procedure qsort1 (var v:m; n:longint);
procedure qSort(l,r:longint);
var i,j,w,q:longint;
begin
  i := l; j := r;
  q := v[(l+r) div 2,1];
  repeat
    while (v[i,1] < q) do inc(i);
    while (q < v[j,1]) do dec(j);
    if (i <= j) then
    begin
      w:=v[i,1]; v[i,1]:=v[j,1]; v[j,1]:=w;
      w:=v[i,2]; v[i,2]:=v[j,2]; v[j,2]:=w;
      inc(i); dec(j);
    end;
  until (i > j);
  if (l < j) then qSort(l,j);
  if (i < r) then qSort(i,r);
end;
begin
qsort(1,n);
end;
var
 mas:m;
 i,n,j:longint;
begin
 read(n);
 for i:=1 to n do
 begin
  read(mas[i,1]);
  mas[i,2]:=i;
 end;
 qsort1(mas,n);
// for i:=1 to n do
//  write(mas[i,1], ' ');
 j:=n;
 for i:=1 to (n div 2) do
 begin
 if mas[i,2]>mas[j,2] then
 writeln(mas[j,2],' ',mas[i,2]) else
  writeln(mas[i,2],' ',mas[j,2]);
  dec(j);
 end;
readln;
readln;
end.

const
        fin='';fon='';
var
        n,s:longint;
        a:array [1..100000] of longint;
procedure nhap;
        var
                i:longint;
        begin
        assign(input,fin);reset(input);
        assign(output,fon);rewrite(output);
        readln(n);
        for i:=1 to n do
                begin
                read(a[i]);
                inc(s,a[i]);
                end;
        s:=s div (N div 2);
        end;
procedure xuat;
        var
                i,j:longint;
        begin
        for i:=1 to n-1 do
                begin
                for j:=i+1 to n do
                        begin
                        if a[i]+a[j]=s then
                                begin
                                writeln(i,' ',j);
                                a[j]:=0;
                                break;
                                end;
                        end;
                end;
        close(input); close(output);
        end;
begin
nhap;
xuat;
end.

var mai,mi,min,max,n,i,o,k:integer;
a:array [1..100]of integer;
begin
read(n);
min:=101;
for i:=1 to n do
read(a[i]);
 while o<n div 2 do
 begin
 inc(o);
 for i:=1 to n do
 begin
 if (a[i]>=max)and(a[i]>0)then begin max:=a[i];mai:=i end ;
 if (a[i]<min)and(a[i]>0)then begin min:=a[i];mi:=i;end;
 end;
 a[mai]:=-1;
 a[mi]:=-1;
 max:=0;
 min:=101;
 writeln(mi,' ',mai);
 end;
 end.

program z1;
type inputar = array[1..100] of longint;
var a,b,c,d,i,j,k,l,m,n:longint; Z:inputar;

Procedure Go(x:longint; a:inputar);
var ans:array[1..100,1..2] of longint; i,j,uk:longint;
begin
uk:=0;
for i:=1 to n do
 for j:=i+1 to n do
 if (a[i]<>-1) and (a[j]<>-1) then
 if a[i]+a[j]=x then
 begin
 inc(uk);
 ans[uk,1]:=i; ans[uk,2]:=j;
 a[i]:=-1; a[j]:=-1;
 end;
if uk=n div 2 then
begin
for i:=1 to uk do writeln(ans[i,1],' ',ans[i,2]);
halt;
end;
end;

begin
//assign(input,'d:\input.txt'); reset(input);
//assign(output,'d:\output.txt'); rewrite(output);
readln(n);
for i:=1 to n do read(Z[i]);
for i:=2 to 200 do
Go(i,Z);
end.

var
   kt:array [0..1000] of boolean;
   a:array [0..1000] of longint;
   i,j,n,s:longint;
begin
readln(n);
for i:=1 to n do
   begin
   read(a[i]);
   s:=s+a[i];
   end;
s:=s*2 div n;
for i:=1 to n do
   if kt[i]=false then
      begin
      kt[i]:=true;
      write(i,' ');
      for j:=i+1 to n do
      if kt[j]=false then
         if s-a[j]=a[i] then
            begin
            writeln(j);
            kt[j]:=true;
            break;
            end;
      end;
end.

var i,j,n:longint;
    a,b:array[0..1100000] of longint;

procedure sort(l,r:longint);
    var
        i,j,x,y:longint;
    begin
        i:=l;
        j:=r;
        x:=a[l+random(r-l+1)];
        repeat
            while (a[i]<x) do
                inc(i);
            while (a[j]>x) do
                dec(j);
            if not(i>j) then
            begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                y:=b[i];
                b[i]:=b[j];
                b[j]:=y;
                inc(i);
                dec(j);
            end;
        until i>j;
        if l<j then
            sort(l,j);
        if (i<r) then
            sort(i,r);
    end;
begin
    readln(n);
    for i:=1 to n do
    begin
        read(a[i]);
        b[i]:=i;
    end;
    sort(1,n);
    i:=1;
    j:=n;
    while (i<j) do
    begin
        writeln(b[i],' ',b[j]);
        inc(i);
        dec(J);
    end;
end.

var n,i,j,k:integer;
    a:array[1..105] of integer;

begin
 readln(n);
 for i:=1 to n do
  begin
   read(a[i]);k:=k+a[i];
  end;
 k:=k*2 div n;
 for i:=1 to n do
  begin
   for j:=i+1 to n do
    if a[i]+a[j]=k then begin writeln(i,' ',j);a[j]:=0; break; end;
  end;
end.

var
  a: array [1..100] of integer;
  i, k, l, j: integer;

begin
  read(k);

  for i := 1 to k do begin read(a[i]);l := l + a[i]; end;

  for i := 1 to k  do
    if a[i] = 0 then continue else
      for j := i+1 to k do
        if a[i] = (l div (k div 2)) - a[j] then begin
          a[i] := 0;
          a[j] := 0;
          writeln(i, ' ', j);
        end;

end.

var a:array[1..100,0..1]of integer;
i,j,n,sw:integer;
begin
     readln(n);
     for i:=1 to n do
     begin
          read(a[i,1]);
          a[i,0]:=i;
     end;
     for j:=1 to n-1 do
         for i:=1 to n-1 do
         if a[i,1] < a[i+1,1] then
         begin
              sw:=a[i,1];
              a[i,1]:=a[i+1,1];
              a[i+1,1]:=sw;
              sw:=a[i,0];
              a[i,0]:=a[i+1,0];
              a[i+1,0]:=sw;
         end;
     i:=1;
     j:=n;
     while i <= j do
     begin
           writeln(a[i,0],' ',a[j,0]);
           i:=i+1;
           j:=j-1;
     end;
end.

var s,n,i,j,d:longint;
    a,ch:array[1..10000] of longint;
begin
  read(n);
   for i:=1 to n do
     begin
     read(a[i]);
       s:=s+a[i];
     end;
   d:=s div (n div 2);
   for i:=1 to n-1 do
      if ch[i]=0 then
    for j:=i+1 to n do
      if ch[j]=0 then
        if a[j]+a[i]=d then
          begin
          ch[j]:=1;
          writeln(i,' ',j);
          break;
          end;

end.

const
   fin='701A.inp';fon='701B.out';
var i,j,n,g,s,t:longint;
   a:array[1..100] of longint;
   kt:array[1..100] of longint;
procedure mo;
begin
assign(input,fin);reset(input);
assign(output,fon);rewrite(output);
end;

procedure solve;
begin
readln(n);
s:=0;
for i:=1 to n do
   begin
   read(a[i]);
   kt[i]:=0;
   s:=s+a[i];
   end;
t:=s div (n div 2);
for i:=1 to n-1 do
   begin
   if kt[i]=0 then
      begin
      kt[i]:=1;
      g:=t-a[i];
      for j:=i+1 to n do
         begin
         if (i<>j) and (kt[j]=0) then
            if a[j]=g then
               begin
               kt[j]:=1;
               writeln(i,' ',j);
               break;
               end;
         end;
      end;
   end;
end;

begin
//mo;
solve;
end.

uses math;
const fi='';
      fo='';
      maxn=101;

var f1,f2:text;
    a,vt:array[0..maxn]of longint;
    n:longint;
procedure openfile;
 begin
  assign(f1,fi);
  reset(f1);
  assign(f2,fo);
  rewrite(f2);
 end;
procedure closefile;
 begin
  close(f1);
  close(f2);
 end;
procedure input;
 var i:longint;
 begin
  readln(f1,n);
  for i:=1 to n do read(f1,a[i]);
 end;

procedure init;
  var i,j,tg:longint;
  begin
   for i:=1 to n do
    vt[i]:=i;
   for i:=1 to n do
    for j:=2 to n do
     if a[j]<a[j-1] then
     begin
      tg:=a[j];a[j]:=a[j-1];a[j-1]:=tg;
      tg:=vt[j];vt[j]:=vt[j-1];vt[j-1]:=tg;
     end;
  end;

procedure solve;
  var i:longint;
  begin
   for i:=1 to n div 2 do
    begin
     writeln(f2,vt[i],' ',vt[n+1-i]);
    end;
  end;

procedure output;

  begin

  end;

begin
 openfile;
 input;
 init;
 solve;
 output;
 closefile;
end.

var
    n,sum,equal,i,j,d : integer;
    a,t,res : array[1..100] of integer;
    kt : array[1..100] of boolean;
BEGIN
    readln(n);
    sum:= 0;
    for i:=1 to n do
        begin
            read(a[i]);
            sum:= sum+a[i];
        end;
    equal:= sum div (n div 2);
    fillchar(kt,sizeof(kt),true);
    d:= 1;
    kt[1]:= false;
    res[1]:= 1;
    t[1]:= a[1];
    for i:=1 to n do
    for j:=1 to n do
        if (kt[j]) and (t[i] <> equal) then
            if t[i] + a[j] = equal then
                begin
                    writeln(res[i],' ',j);
                    t[i]:= t[i]+a[j];
                    kt[j]:= false;
                end
        else if t[i] = 0 then
            begin
                t[i]:= a[j];
                inc(d);
                res[d]:= j;
                kt[j]:= false;
            end;
END.

{$MODE OBJFPC}

Program cf364a;

Const
  Input= '';
  Output= '';

Var
  Fi, fo: text;
  n, i: integer;
  a, id: array[1..100] of integer;

Procedure Enter;
  Begin
    readln(Fi, n);
    for i:=1 to n do
      begin
        read(fi, a[i]);
        id[i]:= i;
      end;
  End;

procedure QS(l, h: integer);
  var i, j, pivot, pivotid: integer;
  begin
    if l>= h then exit;
    i:= l+ random(h-l+1);
    pivot:= a[i]; pivotid:= id[i];
    a[i]:= a[l]; id[i]:= id[l];
    i:= l; j:= h;
    repeat
      while (i<j) and (pivot< a[j]) do dec(j);
      if i<j then
        begin
          a[i]:= a[j];
          id[i]:= id[j];
          inc(i);
        end
      else break;
      while (i<j) and ( a[i]<pivot) do inc(i);
      if i< j then
        begin
          a[j]:= a[i];
          id[j]:= id[i];
          dec(j);
        end
      else break;
    until i= j;
    a[i]:= pivot;
    id[i]:= pivotid;
    QS(l, i-1); QS(i+1, h);
  end;

Procedure Solve;
  Begin
    QS(1, n);
  End;

Procedure Finish;
  Begin
    for i:= 1 to n div 2 do writeln(Fo, id[i],' ', id[n-i+1]);
  End;

Begin
  Assign(Fi, Input); Reset(Fi);
  Assign(Fo, Output); Rewrite(Fo);
  Enter;
  SOlve;
  Finish;
  Close(Fi); Close(Fo);
End.

var
  n, k, q, p, i, z, x: integer;
  mas, mas2: array [1..100] of integer;

begin
  readln(n);
  q := n + 1;
  for i := 1 to n do
    read(mas[i]);

  for i := 1 to n do
  begin
    x := x + 1;
    mas2[i] := x;
  end;

  repeat
    k := 1;
    for i := 1 to n - 1 do
      if mas[i] < mas[i + 1] then
      begin
        p := mas[i];
        mas[i] := mas[i + 1];
        mas[i + 1] := p;
        p := mas2[i];
        mas2[i] := mas2[i + 1];
        mas2[i + 1] := p;
        k := 0;
      end;
  until k = 1;

  for i := 1 to n div 2 do
  begin
    z := z + 1;
    q := q - 1;
    writeln(mas2[z], ' ', mas2[q]);
  end;

end.

var a:array[1..100]of longint;
f:array[1..100]of boolean;
i,n,j,s:longint;
begin
readln(n);
for i:=1 to n do
read(a[i]);
s:=0;
for i:=1 to n do
s:=s+a[i];
fillchar(f,sizeof(f),true);
for i:=1 to n do
if f[i] then
begin
  f[i]:=false;
  write(i,' ');
  for j:=1 to n do
  if (i<>j)and(a[j]+a[i]=s div (n div 2))and(f[j]=true) then
  begin
    f[j]:=false;writeln(j);break;
  end;
end;
end.

var kt:array[0..300]of boolean;
a:array[0..300]of longint;
i,n,m,j,k,s:longint;
begin
readln(n);
m:=n div 2;
for i:=1 to n do
    begin
    read(a[i]);
    s:=s+a[i];
    end;
for i:=1 to n do
    kt[i]:=true;
s:=s div m;
for i:=1 to m do
    begin
    k:=s;
    for j:=1 to n do
        if kt[j]=true then
            begin
            k:=k-a[j];
            write(j,' ');
            kt[j]:=false;
            break;
            end;
    for j:=1 to n do
        if (k-a[j]=0)and(kt[j]=true) then
            begin
            kt[j]:=false;
            writeln(j);
            break;
            end;
    end;
end.

program yan;
  var ar,an:array[1..100]of longint;
      i,j,x,y,a,b,n,m:longint;
begin
  readln(n);
  for i:=1 to n do
    begin
      read(ar[i]);
      an[i]:=i;
    end;
  for i:=1 to n-1 do
    for j:=1 to n-i do
      if ar[j]>ar[j+1] then
        begin
          x:=ar[j]; ar[j]:=ar[j+1]; ar[j+1]:=x;
          x:=an[j]; an[j]:=an[j+1]; an[j+1]:=x;
        end;
  for i:=1 to n div 2 do
    writeln(an[i],' ',an[n-i+1]);
end.

program cards;
const input='';
      output='';
      maxn=100;
var a: array[1..maxn] of integer;
    id: array[1..maxn] of integer;
    n: integer;

procedure enter;
var fi: text;
    i: integer;
begin
   assign(fi,input);
   reset(fi);
   readln(fi,n);
   for i:=1 to n do
      begin
         read(fi,a[i]);
         id[i]:=i;
      end;
   close(fi);
end;

procedure QuickSort(L,R: integer);
var i, j, mid, phu: integer;
begin
   i:=L; j:=R; mid:=a[(L+R) div 2];
   repeat
      while a[i]<mid do inc(i);
      while a[j]>mid do dec(j);
      if i<=j then
         begin
            phu:=a[i];
            a[i]:=a[j];
            a[j]:=phu;
            phu:=id[i];
            id[i]:=id[j];
            id[j]:=phu;
            inc(i);
            dec(j);
         end;
   until i>j;
   if i<R then QuickSort(i,R);
   if L<j then QuickSort(L,j);
end;

procedure init;
begin
   QuickSort(1,n);
end;

procedure xuat;
var fo: text;
    i: integer;
begin
   assign(fo,output);
   rewrite(fo);
   for i:=1 to (n div 2) do writeln(fo,id[i],' ',id[n-i+1]);
   close(fo);
end;

BEGIN
   enter;
   init;
   xuat;
END.

const
  fi='';
var
  a,p:array[0..101] of longint;
  f:text;
  t,i,j,n:longint;
begin
  assign(f,fi); reset(f);
  readln(F,n); for i:=1 to n do read(f,a[i]);
  for i:=1 to n do p[i]:=i;
  close(f);
  for i:=1 to n-1 do
    for j:=n downto i do
      if a[i]>a[j] then
        begin
          t:=a[i]; a[i]:=a[j]; a[j]:=t;
          t:=p[i]; p[i]:=p[j]; p[j]:=t;
        end;
  for i:=1 to n div 2 do writeln(p[i],' ',p[n-i+1]);
  readln;
end.

var
a:array[1..10000]of longint;
n,sum:longint;
c,i,j:longint;
bol:boolean;
begin
readln(N);
for i:=1 to n do begin
read(a[i]);
sum:=sum+a[i];
end;
for i:=1 to n div 2 do begin
bol:=false;
    for j:=1 to n do begin
    for c:=1 to n do
        if (a[j]+a[c]=(sum div (n div 2)))and(j<>c) then begin
            writeln(j,' ',c);
            a[c]:=-10;
            a[j]:=-10;
            bol:=true;
            break;
        end;
        if bol then break;
    end;
end;
end.

var
  n: integer;
  a: array[1..100] of integer;
  i, summ, k, s, j: integer;

begin
  readln(n);
  summ := 0;
  k := n div 2;
  for i := 1 to n do
  begin
    read(a[i]);
    summ := summ + a[i];
  end;

  s := summ div k;

  for i := 1 to n do
    for j := 1 to n do
      if (a[i] + a[j] = s) and (i<>j) then
      begin
        writeln(i, ' ', j);
        a[i] := 0;
        a[j] := 0;
      end;

end.

var i,l,r,n:longint;
    a,cs:array[0..101] of longint;
procedure sort(l,r:longint);
var i,j,x,c:longint;
begin
    i :=l;j :=r;x :=a[l+random(r-l+1)];
    While i<j do
    begin
        While (a[i] < x) do inc(i);
        While (a[j] > x) do dec(j);
        If (i<=j) then
        begin
            c :=a[i];a[i] :=a[j];a[j] :=c;
            c :=cs[i];cs[i] :=cs[j];cs[j] :=c;
            inc(i);dec(j);
        end;
    end;
    If (l<j) then sort(l,j);
    If (i<r) then sort(i,r);
end;
begin
    readln(n);
    For i:=1 to n do
    begin
        read(a[i]);cs[i] :=i;
    end;
    sort(1,n);l :=1;r :=n;
    While l<r do
    begin
        writeln(cs[l],' ',cs[r]);
        inc(l);dec(r);
    end;
end.

var a,b,c:array[1..1000] of longint;
i,n,l,s,s2,n2,j:longint;
begin
  readln(n);
  for i:=1 to n do
  begin
    read(a[i]);
    s:=s+a[i];
  end;
  n2:=n div 2;
  s2:=s div n2;

  for i:=1 to n do
    begin
      for j:=1 to n do
        if (i<>j) and (a[i]+a[j]=s2) then begin
                               l:=l+1;
                               b[l]:=i;
                               c[l]:=j;
                               a[i]:=0;
                               a[j]:=0;
                               break;
                             end;
    end;

  for i:= 1 to l do
    writeln(b[i],' ',c[i]);
end.

var a,c:array[1..100]of byte;n,i:byte;
procedure sort(l,r:byte);
var i,j,x,y:byte;
begin
        i:=l;j:=r;x:=a[(l+r) div 2];repeat while a[i]<x do inc(i);while x<a[j] do
        dec(j);if not(i>j) then
        begin
                y:=a[i];a[i]:=a[j];a[j]:=y;y:=c[i];c[i]:=c[j];c[j]:=y;inc(i);j:=j-1;
        end;until i>j;if l<j then sort(l,j);if i<r then sort(i,r);
end;begin
        readln(n);for i:=1 to n do read(a[i]);for i:=1 to n do c[i]:=i;sort(1,n);
        for i:=1 to n div 2 do writeln(c[i],' ',c[n-i+1]);readln;
end.

var i,t,n,j:integer;
a:array [1..100] of integer;
free:array [1..100] of boolean;
begin
        readln(n);
        t:=0;
        for i:=1 to n do
        begin
                read(a[i]);
                t:=t+a[i];
        end;
        t:=t div (n div 2);
        fillchar(free,sizeof(free),true);
        for i:=1 to n do
        if free[i] then
                for j:=i+1 to n do
                if (free[j]) and (a[i]+a[j]=t) then
                begin
                        free[i]:=false;
                        free[j]:=false;
                        writeln(i,' ',j);
                        break;
                end;
end.

program p1;
var a:array[1..100] of integer;
    i,j,sum,n:integer;
begin
   readln(n);
   for i:=1 to n do read(a[i]);
   for i:=1 to n do sum:=sum+a[i];
   sum:=sum div (n div 2);
   for i:=1 to n-1 do begin
     j:=i+1;
     if a[i]<>0 then begin
         while (a[j]+a[i])<>sum do inc(j);
         writeln(i,' ',j);
         a[j]:=0;
      end;
      end;
end.

program zzz;
var n,i,j,sum:integer;
    a:array[1..100]of integer;
begin
  readln(n);
  sum:=0;
  for i:=1 to n do
  begin
    read(a[i]);
    sum:=sum+a[i];
  end;
  sum:=(sum*2) div n;
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if a[i]+a[j]=sum
      then begin
             writeln(i,' ',j);
             a[i]:=0;
             a[j]:=0;
           end;

end.

var
b:array[1..200]of boolean;
a:array[1..200]of longint;
n,i,j,f,sum:longint;
begin
  fillchar(b,sizeof(b),true);
  read(n);
  for I:=1 to n do
  begin
    read(a[i]);
    sum:=a[i]+sum;
  end;
  sum:=sum*2 div n;
  f:=0;
  for i:=1 to n do
  begin
    if b[i]=true
    then begin
           for j:=i+1 to n do
            if b[j]=true
            then if a[j]+a[i]=sum
                 then begin
                        f:=f+2;
                        b[i]:=false;
                        b[j]:=false;
                        writeln(i,' ',j);
                        break;
                      end;
         end;
    if f=n
    then exit;
  end;
end.

//i am so sorry but i have to do thissssssssssssssssssssssss
const
   fin='701A.inp';fon='701A.out';
var i,j,n,g,s,t:longint;
   a:array[1..100] of longint;
   kt:array[1..100] of longint;
procedure mo;
begin
assign(input,fin);reset(input);
assign(output,fon);rewrite(output);
end;

//plz godddddddd helppppp meeeeeeeee you are the shadow to my life can u feel oooooooooooooooooooooooooo
procedure solve;
begin
readln(n);
s:=0;
for i:=1 to n do
   begin
   read(a[i]);
   kt[i]:=0;
   s:=s+a[i];
   end;
t:=s div (n div 2);
for i:=1 to n-1 do
   begin
   if kt[i]=0 then
      begin
      kt[i]:=1;
      g:=t-a[i];
      for j:=i+1 to n do
         begin
         if (i<>j) and (kt[j]=0) then
            if a[j]=g then
               begin
               kt[j]:=1;
               writeln(i,' ',j);
               break;
               end;
         end;
      end;
   end;
end;

//ho lee schitt
begin
//mo;
solve;
end.
//damn it i failed, plz dont skip me :((

                                {***ABDUMALIK***}
var
  a,b:array [1..100] of integer;
  i,j,n,m,k:integer;
begin
  read(n);
  for i:=1 to n do
    read(a[i]);
  b:=a;
  for i:=1 to n do
    for j:=1 to n do
      if a[i]>a[j] then swap(a[i],a[j]);
  for j:=1 to round(n/2) do
    begin
    for  i:=1 to n do
    if (b[i]=a[j]) and (b[i]<>-5) then begin write(i,' '); b[i]:=-5; break; end;
    for  i:=1 to n do
    if (b[i]=a[n-j+1]) and (b[i]<>-5) then begin writeln(i); b[i]:=-5; break; end;
    end;
end.

var n,i,c,j,b,d,f : integer;
	a : array[1..100] of integer;
	g : array[1..100] of boolean;
begin
	readln(n);
	c := 0;
	 b:= 0;
	 f := 0;
	 fillchar(g,sizeof(g),true);
	for i := 1 to n do
	begin
		read(a[i]);
		c := c+a[i];
	end;
	d := c div (n div 2);

	for i := 1 to n    do
	begin

		if  g[i] then
		begin
			for j := 2 to n do
			begin

				if (i<> j) and (a[i]+a[j] = d) and g[j] then
				begin

					g[i] := false;
					g[j] := false;
					break;
				end;
			end;
			write(i,' ',j);
		writeln;
		end;

	end;
end.

const
  inp = 'input.txt';
  out = 'output.txt';
  maxn = 100;

var
  n, sum : longint;
  a, id : array[0..maxn] of longint;
  free : array[0..maxn] of boolean;

procedure init;
  var i : Longint;
  begin
    sum := 0;
    readln(n);
    for i := 1 to n do
      begin
        read(a[i]);
        id[i] := i;
        sum := sum + a[i];
      end;
    sum := sum div (n div 2);
  end;

procedure solve;
  var i, j : longint;
  begin
    fillchar(free, sizeof(free), true);
    for i := 1 to n - 1 do
      if free[i] then
      begin
        for j := i + 1 to n do
          if free[j] then
            if a[i] + a[j] = sum then
              begin
                writeln(i,' ', j);
                free[j] := false;
                break;
              end;
      end;
  end;

begin
  //assign(input, inp); reset(input);
  //assign(output, out); rewrite(output);
  init;
  solve;
end.

program brbrbrbbr;
var
  A,PR,NUM:array[1..100] of longint;
  n,sum,i,j,pr1:longint;
begin
  {Assign(input,'input.txt');
  Reset(input);
  Assign(output,'output.txt');
  Rewrite(output);}

  readln(n); sum:=0;
  for i:=1 to n do begin read(a[i]); num[i]:=i; inc(sum,a[i]); end;

  sum:=sum div (n div 2);
  for i:=1 to n do if pr[i]=0 then begin
   j:=1; pr1:=0;
   while (j<=n)and(pr1=0) do begin
    if (pr[j]=0)and(a[i]+a[j]=sum)and(i<>j) then begin pr[j]:=1; writeln(i,' ',j); pr1:=1; end;
    inc(j);
   end;
   pr[i]:=1;
  end;

//Close(input); Close(output);
end.

var a:array[1..1000, 1..2]of int64;
    n, i, j, buf:longint;
begin
    readln(n);
    for i:=1 to n do read(a[i, 1]);
    for i:=1 to n do a[i, 2]:=i;
    for i:=1 to n-1 do
      for j:=i+1 to n do if a[i, 1]>a[j, 1] then begin buf:=a[i, 1]; a[i, 1]:=a[j, 1]; a[j, 1]:=buf; buf:=a[i, 2]; a[i, 2]:=a[j, 2]; a[j, 2]:=buf; end;
    for i:=1 to n div 2 do writeln(a[i,2], ' ', a[n-i+1, 2]);
end.

Var a:array[1..100] of longint;sum,i,j,n,u:longint;used:array[1..100] of boolean;
Begin
        readln(n);
        for i:=1 to n do
        begin
        read(a[i]);
        sum:=sum+a[i];
        end;
        u:=sum div (n div 2);
        for i:=1 to n do
        begin
        if used[i]<>true then
        for j:=i+1 to n do
        if (used[j]<>true) and (u-a[i]=a[j]) then
        begin
        writeln(i,' ',j);
        used[i]:=true;
        used[j]:=true;
        break;
        end;
        end;
End.

var
  n: integer;
  a: array[1..100] of integer;
  i, summ, k, s, j: integer;

begin
  readln(n);
  summ := 0;
  k := n div 2;
  for i := 1 to n do
  begin
    read(a[i]);
    summ := summ + a[i];
  end;

  s := summ div k;

  for i := 1 to n do
    for j := 1 to n do
      if (a[i] + a[j] = s) and (i<>j) then
      begin
        writeln(i, ' ', j);
        a[i] := 0;
        a[j] := 0;
      end;

end.

program mirovanie;
var n,i,s,i2:integer; q:array[1..101] of integer;
begin
 readln(n);
 for i:=1 to n do begin read(q[i]); s:=s+q[i]; end;
 s:=s*2 div n;
 for i:=1 to n do
  begin
   if q[i]<>0 then
    for i2:=i+1 to n do
     begin
      if q[i]+q[i2]=s then begin writeln(i,' ',i2); q[i2]:=0; break; end;
     end;
  end;
end.

var j,i,n,s,k:longint; arr:array[1..100] of integer;
begin
readln(n);
for i:=1 to n do
begin
read(arr[i]);
s:=s+arr[i];
end;
k:=(s div (n div 2));
for i:=1 to n do
 begin
 if arr[i]=0 then continue;
 for j:=i+1 to n do
  begin
  if (i=j) or (arr[j]=0) then continue
  else if (arr[i]+arr[j]=k) then begin arr[i]:=0; arr[j]:=0; writeln(i,' ',j);  end;
  end;
 end;
end.

var n: byte;
    cards, answers: array of byte;
    summ, avg: integer;

function InArray(N: byte; arr: array of byte): boolean;
begin
  for var i := 0 to arr.Length - 1 do
    if N = arr[i] then result := true;
end;

begin
  Readln(n);
  cards := new byte [n];
  answers := new byte [n];
  for var i := 0 to n - 1 do
    Read(cards[i]);
  for var i := 0 to n - 1 do
    summ += cards[i];
  avg := Round(summ / (n / 2));
  var counter: integer := 0;
  for var i := 0 to n - 1 do
    for var j := 0 to n - 1 do
    if (i <> j) and (cards[i] + cards[j] = avg) then
    begin
      if (not InArray(i + 1, answers)) and (not InArray(j + 1, answers)) then
      begin
        answers[counter] := i + 1;
        answers[counter + 1] := j + 1;
        counter += 2;
        break;
      end;
    end;

  for var i := 0 to n - 2 do
    if i mod 2 = 0 then
      Writeln(answers[i], ' ', answers[i + 1]);
end.

var
n,i,j,x:longint;
a,ind:array[1..10000]of integer;
begin
readln(n);
for i:=1 to n do read(a[i]);
for i:=1 to n do ind[i]:=i;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then begin
    x:=a[i];
    a[i]:=a[j];
    a[j]:=x;
    x:=ind[i];
    ind[i]:=ind[j];
    ind[j]:=x;
end;
for i:=1 to n div 2 do
writeln(ind[i],' ',ind[n-i+1]);
end.

const
   tfi='';
   tfo='';

type info= record
   val, pos: longint; end;

var
   fi, fo: text;
   n: longint;
   a: array[0..105] of info;

procedure __;
var
   i: longint;
begin
   assign(fi, tfi); reset(fi);
   assign(fo, tfo); rewrite(fo);
   readln(fi, n);
   for i:=1 to n do read(fi, a[i].val);
   for i:=1 to n do a[i].pos := i;
end;

procedure sort(l, r: longint);
var
   i, j, mid: longint;
   tmp: info;
begin
   i:=l;j:=r;
   mid := a[(l+r) div 2].val;
   repeat
      while a[i].val<mid do inc(i);
      while a[j].val>mid do dec(j);
      if i<=j then
         begin
            tmp := a[i]; a[i] := a[j]; a[j] := tmp;
            inc(i); dec(j);
         end;
   until i>j;
   if i<r then sort(i, r);
   if l<j then sort(l, j);
end;

procedure xuly;
var
   i: longint;
begin
   for i:=1 to (n div 2) do
      writeln(fo, a[i].pos,' ', a[n-i+1].pos);
end;

procedure _;
begin
   close(fi); close(fo);
end;

BEGIN
   __;
   sort(1, n);
   xuly;
   _;
END.

var
	n,i,j,sum			:longint;
	a					:array[0..1005] of longint;
	v					:array[0..1005] of boolean;
begin
	read(n);
	for i:=1 to n do
	begin
		read(a[i]);
		inc(sum,a[i]);
	end;
	sum:=sum div (n div 2);
	for i:=1 to n do
	begin
		if not v[i] then
		begin
			v[i]:=true;
			for j:=i+1 to n do
			begin
				if v[j] then continue;
				if a[i]+a[j]=sum then
				begin
					writeln(i,' ',j);
					v[j]:=true;
					break;
				end;
			end;
		end;
	end;
end.

var a,b,c:array[1..1000] of longint;
i,n,l,s,s2,n2,j:longint;
begin
  readln(n);
  for i:=1 to n do
  begin
    read(a[i]);
    s:=s+a[i];
  end;
  n2:=n div 2;
  s2:=s div n2;

  for i:=1 to n do
    begin
      for j:=1 to n do
        if (i<>j) and (a[i]+a[j]=s2) then begin
                               l:=l+1;
                               b[l]:=i;
                               c[l]:=j;
                               a[i]:=0;
                               a[j]:=0;
                               break;
                             end;
    end;

  for i:= 1 to l do
    writeln(b[i],' ',c[i]);
end.

var
a:array[1..101] of longint;
used:array[1..101] of boolean;
i,n,s,each,j,k,p:longint;
begin
readln(n);
s:=0;
for i:=1 to n do
begin
read(a[i]);
s:=s+a[i];
end;
each:=(s*2) div n;
for i:=1 to n do
used[i]:=false;

for i:=1 to (n div 2) do
begin
        for j:=1 to n do
        if not used[j] then
                begin
                write(j,' ');
                used[j]:=true;
                p:=a[j];
                break;
                end;

        for k:=j+1 to n do
        if (not used[k])  and (a[k]=each-p) then
                begin
                writeln(k);
                used[k]:=true;
                break;
                end;

end;

end.

var
n,u,i,o:longint;
a:array[1..100]of longint;
begin
readln(n); u:=0;
for i:=1 to n do
begin read(a[i]);
inc(u,a[i]); end;
u:=u div (n div 2);
for i:=1 to n-1 do
for o:=i+1 to n do
if a[i]+a[o]=u then
begin a[o]:=-1000000;
a[i]:=a[o];
writeln(i,' ',o); end;
end.

var
a:array[1..101] of longint;
n,i,j,b,n1:longint;

begin
 readln(n);
 for i:=1 to n do
 begin
  read(a[i]);
  b:=b+a[i];
 end;
 n1:=n div 2;
 b:=b div n1;
 for i:=1 to n do
  begin
    if a[i]<>0 then begin
                     for j:=i+1 to n do
                      begin
                       if a[i]+a[j]=b then begin
                                            writeln(i,' ',j);
                                            a[i]:=0;
                                            a[j]:=0;
                                           end;
                      end;
                    end;
  end;
end.

program O_O;
 var
  i,j,k,n:longint;
  a,b:array[1..100] of longint;
  f:array[0..101] of longint;
procedure init;
 var
  i:longint;
begin
  readln(n);
  for i:=1 to n do
   begin
    read(a[i]);
    b[i]:=i;
   end;
end;
procedure sort;
 var
  i,j,t:longint;
begin
  for i:=1 to n-1 do
   for j:=i+1 to n do
    if a[i]>a[j] then
     begin
      t:=a[i];a[i]:=a[j];a[j]:=t;
      t:=b[i];b[i]:=b[j];b[j]:=t;
     end;
end;
procedure print;
 var
  i:longint;
begin
 for i:=1 to n div 2 do
  writeln(b[i],' ',b[n-i+1]);
end;
begin
  init;
  sort;
  print;
end.

var j,i,n,s,k:longint; arr:array[1..100] of integer;
begin
readln(n);
for i:=1 to n do
begin
read(arr[i]);
s:=s+arr[i];
end;
k:=(s div (n div 2));
for i:=1 to n do
 begin
 if arr[i]=0 then continue;
 for j:=i+1 to n do
  begin
  if (i=j) or (arr[j]=0) then continue
  else if (arr[i]+arr[j]=k) then begin arr[i]:=0; arr[j]:=0; writeln(i,' ',j);  end;
  end;
 end;
end.

program z;
type card=record
         ind,num:byte;
         end;

var n:byte;
       a:array[1..100] of card;
       tmp:card;
       i,j:byte;
begin
    read(n);
    for i:=1 to n do
      begin
            read(a[i].num);
            a[i].ind:=i;
      end;

    for i:=1 to n do
    for j:=n downto i+1 do
        if a[j].num<a[j-1].num then
            begin
               tmp:=a[j];
               a[j]:=a[j-1];
               a[j-1]:=tmp;
             end;

     i:=1; j:=n;
     while i<j do
       begin
        writeln(a[i].ind,' ',a[j].ind);
        inc(i); dec(j);
       end;
 end.

program Aproblem;
var a,v:array[0..100] of integer;
    i,n,s,ii:integer;
begin
     readln(n); s:=0;
     for i:=1 to n do
     begin
          read(a[i]);
          s:=s+a[i];
     end;
     s:=trunc(2*s/n);
     fillchar(v,sizeof(v),0);
     for i:=1 to n do
     begin
          if v[i]=0 then
          begin
          for ii:=1 to n do
          begin
               if (i<>ii) and (a[i]+a[ii]=s) and (v[ii]=0) and (v[i]=0) then
               begin
               writeln(i,' ',ii);
               v[i]:=1;v[ii]:=1;
               end;
          end;
          end;
     end;
end.

var n,i,sum,j:integer;
a:array[1..100] of integer;
f:array[1..100] of boolean;

begin
read(n);
sum:=0;
for i:=1 to n do
begin
read(a[i]);
sum:=sum+a[i];
end;
sum:=sum div (n div 2);
for i:=1 to n do
 begin
 if f[i]=false then
   begin
   j:=i+1;
   while not ((a[j]+a[i]=sum) and (f[j]=false)) do
   inc(j);
   writeln(i,' ',j);
   f[i]:=true;
   f[j]:=true;
   end;
 end;
end.

var a,b:array [1..1111] of longint; n,i,j,s:longint;
begin
  readln (n);
  for i:=1 to n do read (a[i]);
  s:=0;
  for i:=1 to n do s:=s+a[i];
  s:=s div (n div 2);
  i:=1;
  while i<=n do
   begin
     if b[i]=0 then
       begin
         b[i]:=1;
         j:=i+1;
         while (a[i]+a[j]<>s) or (b[j]=1) do j:=j+1;
         writeln (i,' ',j);
         b[j]:=1;
       end;
     i:=i+1;
   end;

end.

var mai,mi,min,max,n,i,o,k:integer;
a:array [1..100]of integer;
begin
read(n);
min:=101;
for i:=1 to n do
read(a[i]);
 while o<n div 2 do
 begin
 inc(o);
 for i:=1 to n do
 begin
 if (a[i]>=max)and(a[i]>0)then begin max:=a[i];mai:=i end ;
 if (a[i]<min)and(a[i]>0)then begin min:=a[i];mi:=i;end;
 end;
 a[mai]:=-1;
 a[mi]:=-1;
 max:=0;
 min:=101;
 writeln(mi,' ',mai);
 end;
 end.

        {$mode objfpc}
        {$coperators on}
uses math;
const
        {$ifdef online_judge}  fi=''; fo='';
        {$else} fi='inp.inp';
                fo='out.out';
        {$endif}
var
        n, sl : longint;
        a : array[1..100] of longint;
        f : array[1..100] of boolean;
        r : array[1..100] of record x,y:integer; end;
        s : longint;
procedure enter;
var i, j : integer;
        begin
                        readln(n);
                        for i:=1 to n do
                                begin
                                        read(a[i]);
                                        s+=a[i];
                                end;
        end;
procedure solve;
var i, j, d: integer;
        begin
                s:=s div (n div 2);
                d:=0;
                repeat
                        d+=2;
                        i:=1;
                        while (i<=n)and(f[i]) do i+=1;
                        f[i]:=true;
                        j:=i+1;
                        while ((j<=n)and(f[j]))or(a[j]+a[i]<>s)do j+=1;
                        f[j]:=true;
                        sl+=1;
                        r[sl].x:=i; r[sl].y:=j;
                until d=n;
                for i:=1 to sl do writeln(r[i].x, ' ', r[i].y);
        end;
begin

        assign(input, fi); assign(output, fo); reset(input);  rewrite(output);
        enter;
        solve;
end.

var n , i, j, sum, sum1 : longint;
    A : array [1..200] of longint;
begin
   readln(n);
   for i := 1 to n do
      read(A[i]);
   sum := 0;
   sum1 := 0;
   for i := 1 to n do
      sum := sum + A[i];
   sum := sum div (n div 2);
   for i := 1 to n do
      for j := 1 to n do
         if (A[i] + A[j] = sum) and (i <> j) then
         begin
            writeln(i,' ', j);
            A[i] := 200;
            A[j] := 200;
            break;
         end;
end.

var
        a,pos : array[1..100] of longint;
        i,n : longint;

procedure swap(var x,y : longint);
        var
                tmp : longint;
        begin
                tmp := x;
                x := y;
                y := tmp;
        end;

procedure qsort(l,r : longint);
        var
                i,j,k : longint;
        begin
                i := l;
                j := r;
                k := a[l+random(r-l+1)];
                while i < j do begin
                        while a[i] < k do inc(i);
                        while a[j] > k do dec(j);
                        if i <= j then begin
                             swap(a[i],a[j]);
                             swap(pos[i],pos[j]);
                             inc(i);
                             dec(j);
                        end;
                end;
                if l < j then qsort(l,j);
                if i < r then qsort(i,r);
        end;

begin
        readln(n);
        for i := 1 to n do begin
                read(a[i]);
                pos[i] := i;
        end;
        qsort(1,n);
        for i := 1 to n div 2 do
                writeln(pos[i],' ',pos[n-i+1]);
end.

var i,j,n,k,k1,q:longint;
    a:array[1..100,1..2] of longint;
BEGIN
readln(n);
for i:=1 to n do
 a[i,2]:=i;
for i:=1 to n do
 read(a[i,1]);

for i := 1 to n-1 do
 for j := 1 to n-i do
  if a[j,1] > a[j+1,1] then
   begin
    k:=a[j,1];
    k1:=a[j,2];
    a[j,1]:=a[j+1,1];
    a[j,2]:=a[j+1,2];
    a[j+1,1]:=k;
    a[j+1,2]:=k1;
   end;

  q:=n;
for i:=1 to n div 2 do
  begin
  writeln(a[i,2],' ',a[q,2]);
  dec(q);
  end;

END.

begin
 var n:=readinteger();
 var a:=arr(0)*n;
 var s:=0;
 for var i:=0 to n-1 do
 begin
   read(a[i]);
   s+=a[i];
 end;
 if s div (n)=a[0] then
 begin
   for var i:=1 to n div 2 do
     writeln(i*2-1,' ',i*2);
   exit();
 end;
 var x:=s div (n div 2);
  for var i:=0 to n-1 do
  begin
    if a[i]=-1 then
      continue;
    var g:=x-a[i];
    for var j:=i to n-1 do
    begin
      if a[j]=-1 then
        continue;
      if (g=a[j])and(j<>i) then
      begin
        a[i]:=-1;
        a[j]:=-1;
        writeln(i+1,' ',j+1);
        break;
      end;
      end;
  end;
end.

begin
 var n:=readinteger();
 var a:=arr(0)*n;
 var s:=0;
 for var i:=0 to n-1 do
 begin
   read(a[i]);
   s+=a[i];
 end;
 if s div (n)=a[0] then
 begin
   for var i:=1 to n div 2 do
     writeln(i*2-1,' ',i*2);
   exit();
 end;
 var x:=s div (n div 2);
  for var i:=0 to n-1 do
  begin
    var g:=x-a[i];
    for var j:=i to n-1 do
      if (g=a[j])and(j<>i) then
      begin
        writeln(i+1,' ',j+1);
        break;
      end;
  end;
end.

var n,i,tong,tb,j:longint;
                a:array[1..100]of integer;
begin
        readln(n);
        for i:=1 to n do
        begin
        read(a[i]);
        tong:=tong+a[i];
        end;
        tb:=tong*2 div n;
        for i:=1 to n do
        begin
        for j:=i+1 to n do
        if a[i] + a[j] = tb then
        begin
        writeln(i,' ',j);
        break;
        end;
        end;
        readln;
end.

var
b:array[1..200]of boolean;
a:array[1..200]of longint;
n,i,j,f,sum:longint;
begin
  fillchar(b,sizeof(b),true);
  read(n);
  for I:=1 to n do
  begin
    read(a[i]);
    sum:=a[i]+sum;
  end;
  sum:=sum*2 div n;
  f:=0;
  for i:=1 to n do
  begin
    if b[i]=true
    then begin
           for j:=i+1 to n do
            if b[j]=true
            then if a[j]+a[i]=sum
                 then begin
                        f:=f+2;
                        b[i]:=false;
                        b[j]:=false;
                        writeln(i,' ',j);
                      end;
         end;
    if f=n
    then exit;
  end;
end.

Const Finp='';
      Fout='';
      maxN=100;
Var n,val:longint;
    a,dau:array[1..maxN] of longint;

Procedure Nhap;
Var f:Text;
    i:longint;
Begin
    assign(f,finp); reset(f);
    readln(f,n);
    for i:=1 to n do
        read(f,a[i]);
    close(f);
End;
Procedure FindVal;
Var i,j,sum:longint;
Begin
    sum:=0;
    for i:=1 to n do
        sum:=sum+a[i];
    val:=(sum div n)*2;
End;
Procedure Xuat;
Var f:Text;
    i,j,cnt,lc:longint;
Begin
    assign(f,fout); rewrite(f);
    fillchar(dau,sizeof(dau),0);
    cnt:=0; lc:=0;
    for i:=1 to n-1 do
        if dau[i]=0 then
        begin
            for j:=i+1 to n do
                if (a[i]+a[j]=val) and (dau[j]=0) then
                    begin
                        dau[j]:=1;
                        writeln(f,i,' ',j);
                        inc(cnt);
                        if cnt=n div 2 then
                            lc:=1;
                        break;
                    end;
            if lc=1 then
                break;
        end;
    close(f);
End;

Begin
    nhap;
    findval;
    xuat;
End.

program zzz;
var n,i,j,sum:integer;
    a:array[1..100]of integer;
begin
  readln(n);
  sum:=0;
  for i:=1 to n do
  begin
    read(a[i]);
    sum:=sum+a[i];
  end;
  sum:=(sum div n)*2;
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if a[i]+a[j]=sum
      then begin
             writeln(i,' ',j);
             a[i]:=0;
             a[j]:=0;
           end;

end.

Var
    n, k: Integer;
    a: Array [1..100] of Integer;

Begin
    Read(n);
    For Var i := 1 to n do
       Read(a[i]);
    For Var i := 1 to n - 1 do
      For Var j := 1 to n - i do
        If a[j] > a[j + 1] then Begin
          k := a[j];
          a[j] := a[j + 1];
          a[j + 1] := k
        End;
    For Var i := 1 to n div 2 do
      Writeln(i, ' ', n - i + 1)
End.

//i am so sorry but i have to do thissssssssssssssssssssssss
const
   fin='701A.inp';fon='701A.out';
var i,j,n,g,s,t:longint;
   a:array[1..100] of longint;
   kt:array[1..100] of longint;
procedure mo;
begin
assign(input,fin);reset(input);
assign(output,fon);rewrite(output);
end;

//plz godddddddd helppppp meeeeeeeee you are the shadow to my life can u feel oooooooooooooooooooooooooo
procedure solve;
begin
readln(n);
s:=0;
for i:=3 to n do
   begin
   read(a[i]);
   kt[i]:=0;
   s:=s+a[i];
   end;
t:=s div (n div 2);
for i:=1 to n-1 do
   begin
   if kt[i]=0 then
      begin
      kt[i]:=1;
      g:=t-a[i];
      for j:=i+1 to n do
         begin
         if (i<>j) and (kt[j]=0) then
            if a[j]=g then
               begin
               kt[j]:=1;
               writeln(i,' ',j);
               break;
               end;
         end;
      end;
   end;
end;

//ho lee schitt
begin
//mo;
solve;
end.
//damn it i failed, plz dont skip me :((

Var a:array[1..100] of longint;sum,i,j,n,u:longint;used:array[1..100] of boolean;
Begin
        readln(n);
        for i:=1 to n do
        begin
        read(a[i]);
        sum:=sum+a[i];
        end;
        u:=(sum div n)*2;
        for i:=1 to n do
        begin
        if used[i]<>true then
        for j:=i+1 to n do
        if (used[j]<>true) and (u-a[i]=a[j]) then
        begin
        writeln(i,' ',j);
        used[i]:=true;
        used[j]:=true;
        end;
        end;
End.

Var a:array[1..100] of longint;sum,i,j,n,u:longint;used:array[1..100] of boolean;
Begin
        readln(n);
        for i:=1 to n do
        begin
        read(a[i]);
        sum:=sum+a[i];
        end;
        u:=(sum div n)*2;
        for i:=1 to n do
        begin
        if used[i]<>true then
        for j:=i+1 to n do
        if (used[j]<>true) and (u-a[i]=a[j]) then
        begin
        writeln(i,' ',j);
        used[i]:=true;
        used[j]:=true;
        break;
        end;
        end;
End.

var
 a,b,c,d,n,m,p,i,i2,i4:integer;
 q:array[1..100] of integer;
 w:array[1..100] of integer;
 s:string;
Begin
 readln(p);
 m:=999;
 n:=0;
 for i:=1 to p do begin
 read(q[i]);
 if n<q[i] then n:=q[i];
 if m>q[i] then m:=q[i];
 end;

 for i:=1 to n do
 for i2:=1 to n do
  if ((n+m)-(q[i]+q[i2])=0) and (i<>i2) and (q[i]<>0) and (q[i2]<>0) then begin
   writeln(i,' ',i2);
   q[i]:=0;
   q[i2]:=0;
  end;
end.

var
   kt:array [0..1000] of boolean;
   a:array [0..1000] of longint;
   i,j,n,s:longint;
begin
readln(n);
for i:=1 to n do
   begin
   read(a[i]);
   s:=s+a[i];
   end;
s:=s*2 div n;
for i:=1 to n do
   if kt[i]=false then
      begin
      kt[i]:=true;
      write(i,' ');
      for j:=i+1 to n do
         if s-a[j]=a[i] then
            begin
            writeln(j);
            kt[j]:=true;
            break;
            end;
      end;
end.

const
        fin='';fon='';
var
        n,s:longint;
        a:array [1..100000] of longint;
procedure nhap;
        var
                i:longint;
        begin
        assign(input,fin);reset(input);
        assign(output,fon);rewrite(output);
        readln(n);
        for i:=1 to n do
                begin
                read(a[i]);
                inc(s,a[i]);
                end;
        s:=s div (N div 2);
        end;
procedure xuat;
        var
                i,j:longint;
        begin
        for i:=1 to n-1 do
                begin
                for j:=i+1 to n do
                        begin
                        if a[i]+a[j]=s then
                                begin
                                writeln(i,' ',j);
                                a[j]:=0;
                                end;
                        end;
                end;
        close(input); close(output);
        end;
begin
nhap;
xuat;
end.

VAR
  n:longint;
  a,b:array[1..100] of longint;

Procedure Nhap;
  Var
    i:longint;
  Begin
    Read(n);
    For i:=1 to n do
      BEgin
        Read(a[i]);
        b[i]:=i;
      End;
  End;

Procedure Xuli;
  VAr
    i,j,x:longint;
  Begin
    For i:=1 to n-1 do
      For j:=i+1 to n do
        If a[i]<a[j] then
          Begin
            x:=a[i];
            a[i]:=a[j];
            a[j]:=x;
            x:=b[i];
            b[i]:=b[j];
            b[j]:=x;
          End;
    For i:=1 to n div 2 do Writeln(i,' ',n-i+1);
  End;

BEGIN
  Nhap;
  Xuli;
END.

var j,i,n,s,k:longint; arr:array[1..100] of integer;
begin
readln(n);
for i:=1 to n do
begin
read(arr[i]);
s:=s+arr[i];
end;
k:=2*(s div n);
for i:=1 to n do
 begin
 if arr[i]=0 then continue;
 for j:=1 to n do
  begin
  if (i=j) or (arr[j]=0) then continue;
  if arr[i]+arr[j]=k then begin arr[i]:=0; arr[j]:=0; writeln(i,' ',j); end;
  end;
 end;
end.

var j,i,n,s,k:integer; arr:array[1..100] of integer;
begin
read(n);
for i:=1 to n do
begin
read(arr[i]);
s+=arr[i];
end;
k:=2*(s div n);
for i:=1 to n do
 begin
 if arr[i]=0 then continue;
 for j:=1 to n do
  begin
  if i=j then continue;
  if arr[i]+arr[j]=k then begin arr[i]:=0; arr[j]:=0; writeln(i,' ',j); end;
  end;
 end;
end.

var j,i,n,s,k:longint; arr:array[1..100] of integer;
begin
readln(n);
for i:=1 to n do
begin
read(arr[i]);
s:=s+arr[i];
end;
k:=2*(s div n);
for i:=1 to n do
 begin
 if arr[i]=0 then continue;
 for j:=1 to n do
  begin
  if i=j then continue;
  if arr[i]+arr[j]=k then begin arr[i]:=0; arr[j]:=0; writeln(i,' ',j); end;
  end;
 end;
end.

var j,i,n,s,k:longint; arr:array[1..100] of integer;
begin
readln(n);
for i:=1 to n do
begin
read(arr[i]);
s+=arr[i];
end;
k:=2*(s div n);
for i:=1 to n do
 begin
 if arr[i]=0 then continue;
 for j:=1 to n do
  begin
  if i=j then continue;
  if arr[i]+arr[j]=k then begin arr[i]:=0; arr[j]:=0; writeln(i,' ',j); end;
  end;
 end;
end.

var a :array [1..100] of integer;
    use : array [1..100] of boolean;
    s, i, j, n : longint;
begin
    readln(n);
    for i := 1 to n do begin
        read(a[i]);
        s := s + a[i];
    end;
    s := (s div n) * 2;
    for i := 1 to n do
        if not use[i] then begin
            use[i] := true;
            for j := i + 1 to n do
                if a[j] = s - a[i] then begin
                    writeln(i, ' ', j);
                    use[j] := true;
                    break;
                end;
        end;
end.

Var i , n , j , tmp : Integer;
    A , B : Array [1..100] of Integer;

Begin
Readln(n); tmp := 0;
Fillchar(B , sizeof(B) , 0);
For i := 1 to n do
    Begin
    Read(A[i]);
    tmp := tmp + A[i];
    End;
tmp := tmp div n * 2;
For i := 1 to n do
    For j := 1 to n do
        If i <> j then
        If (B[i] = 0) and (B[j] = 0) then
        If A[i] + A[j] = tmp then
            Begin
            Writeln(i ,' ', j);
            B[i] := 1;
            B[j] := 1;
            End;
If n = 2 then Writeln('1 2');
End.

Var i , n , j , tmp : Integer;
    A , B : Array [1..100] of Integer;

Begin
Readln(n); tmp := 0;
Fillchar(B , sizeof(B) , 0);
For i := 1 to n do
    Begin
    Read(A[i]);
    tmp := tmp + A[i];
    End;
tmp := tmp div n * 2;
For i := 1 to n do
    For j := 1 to n do
        If i <> j then
        If (B[i] = 0) and (B[j] = 0) then
        If A[i] + A[j] = tmp then
            Begin
            Writeln(i ,' ', j);
            B[i] := 1;
            B[j] := 1;
            End;
End.

program cards;
var i,j,s,max:integer;
    a,num,sp:array[1..1000] of integer;
    v:array[1..1000] of boolean;
begin
     s:=0;fillchar(v,sizeof(v),false);
     for i:=1 to 5 do
     begin
          read(a[i]);
          s:=s+a[i];
          num[a[i]]:=num[a[i]]+1;
     end;
     for i:=1 to 5 do
     begin
          if (num[a[i]]=2) and (v[i]=false) then begin sp[i]:=a[i]*num[a[i]];for j:=1 to 5 do if a[j]=a[i] then v[j]:=true; end;
          if (num[a[i]]>=3) and (v[i]=false) then begin sp[i]:=a[i]*3;for j:=1 to 5 do if a[j]=a[i] then v[j]:=true;end;
     end;
     for i:=1 to 5 do
     if max<=sp[i] then max:=sp[i];
     writeln(s-max);
end.

program Aproblem;
var a,v:array[0..100] of integer;
    i,n,s,ii:integer;
begin
     readln(n); s:=0;
     for i:=1 to n do
     begin
          read(a[i]);
          s:=s+a[i];
     end;
     s:=trunc(2*s/n);
     fillchar(v,sizeof(v),0);
     for i:=1 to n do
     begin
          if v[i]=0 then
          begin
          for ii:=1 to n do
          begin
               if (i<>ii) and (a[i]+a[ii]=s) and (v[ii]=0) then
               begin
               writeln(i,' ',ii);
               v[i]:=1;v[ii]:=1;
               end;
          end;
          end;
     end;
end.

program cards;
var i,j,s,max:integer;
    a,num,sp:array[1..1000] of integer;
    vv:array[1..1000] of boolean;
begin
     s:=0;fillchar(vv,sizeof(vv),false);
     for i:=1 to 5 do
     begin
          read(a[i]);
          s:=s+a[i];
          num[a[i]]:=num[a[i]]+1;
     end;
     for i:=1 to 5 do
     begin
          if (num[a[i]]=2) and (vv[i]=false) then begin sp[i]:=a[i]*num[a[i]];for j:=1 to 5 do if a[j]=a[i] then vv[j]:=true; end;
          if (num[a[i]]>=3) and (vv[i]=false) then begin sp[i]:=a[i]*3;for j:=1 to 5 do if a[j]=a[i] then vv[j]:=true;end;
     end;
     for i:=1 to 5 do
     if max<=sp[i] then max:=sp[i];
     writeln(s-max);
end.