import java.io.*; import java.util.*; import java.lang.*; import static java.lang.System.out; public class help { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer pstk = new StringTokenizer(""); static String pline; public static void main(String[] args)throws Exception { /* String line; StringTokenizer stk; line = br.readLine(); //compareTo("end")!0 stk = new StringTokenizer(line); stk.nextToken(line);*/ while(priklad()); } public List stack; public static boolean priklad() throws Exception { int pocet = readInt(); if(pocet == 0) return false; long A = 0; long B = 0; ArrayList list = new ArrayList(); for (int i = 0; i < pocet; i++) { list.add(readInt()); } for (int i = 0; i < pocet; i++) { if ( (Integer)list.get(i) == 100000) { list.remove(i); A = 100000; out.print("100000-A "); break; } } Collections.sort(list); /*for (Object i: list) { out.print((Integer)i+" "); }*/ int n; while ((n = list.size()) > 0) { int max = (int)(A - B); if (max < 0) max = -max; max += 100000; int castka; /*if (n == 0) return true;*/ for (int i = n-1; i >= 0; i--) { //out.println("max=" + max + " hodnota=" + list.get(i)); if (( castka = list.get(i) ) <= max) { list.remove(i); //out.println("remove " + i + " size=" + n); if (A > B) { out.print(castka + "-B "); B += castka; } else { out.print(castka + "-A "); A += castka; } break; } } } out.println(); return true; } public static int readInt() throws Exception { return Integer.parseInt(readToken()); } public static String readToken() throws Exception { while (!pstk.hasMoreTokens()) pstk = new StringTokenizer(pline = br.readLine()); return pstk.nextToken(); } }