/** * Sample solution to Gallup * Uses only integer arithmatic. * Author: Mikael Goldmann */ import java.util.*; import java.io.*; class Gallup { static final int MAX = 10000; static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter stdout = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out))); public static void main(String args[]) { int cnt = 0; try { while( solve(++cnt) ); } catch (Exception e) { /* skip */} stdout.close(); } static boolean solve(int cnt) throws Exception { String s=""; int i; StringTokenizer st = new StringTokenizer(stdin.readLine()); int np = Integer.parseInt(st.nextToken()); double[] p = new double[np]; long[] a = new long[np]; if (np == 0) return false; stdout.print("Case " + cnt + ": "); for (i = 0; i < np; ++i) { s = st.nextToken(); p[i] = Double.parseDouble(s); } i = s.indexOf('.'); int ndec = 0; if (i != -1) ndec = s.length()-i-1; long exp_10_d = 1; for (i = 0; i < ndec; ++i) exp_10_d *= 10; for (i = 0; i < np; ++i) a[i] = (long)(exp_10_d * p[i] + 0.1); long minpeople; long lo,hi; long losum, hisum; boolean ok = true; for (minpeople = 1; minpeople < MAX; ++minpeople) { losum = hisum = 0; ok = true; for (i = 0; ok && i < np; ++i) { lo = ((2*a[i]-1)*minpeople)/(2*100*exp_10_d); hi = 1+((2*a[i]+1)*minpeople)/(2*100*exp_10_d); while (2*100*exp_10_d*lo < minpeople*(2*a[i]-1)) ++lo; while (2*100*exp_10_d*hi >= minpeople*(2*a[i]+1)) --hi; ok = (lo <= hi); losum += lo; hisum += hi; } if (ok && losum <= minpeople && hisum >= minpeople) break; } if (ok && minpeople < MAX) stdout.println(minpeople); else stdout.println("error"); return true; } }