The Strange Research

Professor A. Karim is working on a project of measuring the surface area of an unknown unearthly object. After a lot of calculation he finds that the surface area of that object is (a + b) ∗ (1 − a ∗ b), where a and b are two parameters related to surface area of that object. With the help of some more advanced experiments he finds N floating-point numbers, which can be possible values of a and b. From the N numbers he can select two values for a and b in N C2 ways (Note that the selections a = 2, b = 3 and a = 3, b = 2 are considered same because (a+b)∗(1−a∗b) is equal to (b+a)∗(1−b∗a)). Karim needs to do some more expensive experiments to find out the real value of a and b, but before doing that he wants to keep only the obvious choices: the selections, which cause the surface of the object to be positive (Greater than zero). Your job is to help Prof. Karim to count how many of the NC2 selections (the value of a and b) causes (a + b) ∗ (1 − a ∗ b) to be positive. Please note that your method must be efficient. (An O(N2) solution will not do) Input The input fine contains maximum 7 sets of inputs. First line of each set contains an integer N (0 < N ≤ 10000). Each of the next N lines contains one floating-point number F (|F | < 30000.0). The meaning of N is given in the problem statement. The input can have the same number twice or even more times. In such cases two same numbers should be considered different. Input is terminated by a case where the value of N is zero. This case should not be processed. Output For each set of input produce one line of output. This line contains the serial no of output followed by an integer which indicates how many of the N C2 selections will cause the value of the expression (a + b) ∗ (1 − a ∗ b) to be positive. Look at the output for sample input for details. You can consider any value greater than 10−15 is positive. Sample Input 5 8197.4013 -3622.8175 -1495.5118 -3958.2735 -678.2750 5 -1208.8234 1465.1943 2699.873 -6665.3587 -4344.6286 3 -20.0 -20.0 -20.0 0

2/2 Sample Output Case 1: 10 Case 2: 5 Case 3: 3