importjava.io.FileInputStream; importjava.io.InputStreamReader; importjava.io.BufferedReader; importjava.io.OutputStreamWriter; importjava.io.PrintWriter; importjava.io.StreamTokenizer; importjava.util.ArrayList; importjava.math.BigInteger; publicclassMain{ publicstaticfinalbooleanDEBUG=false; publicStreamTokenizertokenizer; publicBufferedReadercin; publicPrintWritercout; publicArrayList<Integer>v=newArrayList<Integer>(); publicvoidinit() { try { if (DEBUG) { cin=newBufferedReader(newInputStreamReader( newFileInputStream("d:\\OJ\\uva_in.txt"))); } else { cin=newBufferedReader(newInputStreamReader(System.in)); } cout=newPrintWriter(newOutputStreamWriter(System.out)); tokenizer=newStreamTokenizer(cin); } catch (Exceptione) { e.printStackTrace(); } } publicStringnext() { try { tokenizer.nextToken(); if (tokenizer.ttype==StreamTokenizer.TT_EOF) returnnull; elseif (tokenizer.ttype==StreamTokenizer.TT_NUMBER) { returnString.valueOf((int)tokenizer.nval); } elseif (tokenizer.ttype==StreamTokenizer.TT_WORD) { returntokenizer.sval; } elsereturnnull; } catch (Exceptione) { e.printStackTrace(); returnnull; } } publicbooleaninput() { v.clear(); while (true) { Strings=next(); if (s==null) returnfalse; if ("-999999".compareTo(s) ==0) break; else { v.add(Integer.parseInt(s)); } } returntrue; } publicvoidsolve() { BigIntegerMin=BigInteger.valueOf(v.get(0)), Max=Min; BigIntegerans=Max; for (inti=1, len=v.size(); i<len; i++) { BigIntegerM=BigInteger.valueOf(v.get(i)); if (M.compareTo(BigInteger.valueOf(v.get(i)).multiply(Max)) <0) { M=BigInteger.valueOf(v.get(i)).multiply(Max); } if (M.compareTo(BigInteger.valueOf(v.get(i)).multiply(Min)) <0) { M=BigInteger.valueOf(v.get(i)).multiply(Min); } BigIntegerm=BigInteger.valueOf(v.get(i)); if (m.compareTo(BigInteger.valueOf(v.get(i)).multiply(Max)) >0) { m=BigInteger.valueOf(v.get(i)).multiply(Max); } if (m.compareTo(BigInteger.valueOf(v.get(i)).multiply(Min)) >0) { m=BigInteger.valueOf(v.get(i)).multiply(Min); } Max=M; Min=m; if (ans.compareTo(Max) <0) { ans=Max; } } cout.println(ans.toString()); cout.flush(); } publicstaticvoidmain(String[] args) { Mainsolver=newMain(); solver.init(); while (solver.input()) { solver.solve(); } } }