- /***********Template Starts Here***********/ 
- #include <bits/stdc++.h> 
-   
- #define pb push_back 
- #define nl puts ("") 
- #define sp printf ( " " ) 
- #define phl printf ( "hello\n" ) 
- #define ff first 
- #define ss second 
- #define POPCOUNT __builtin_popcountll 
- #define RIGHTMOST __builtin_ctzll 
- #define LEFTMOST(x) (63-__builtin_clzll((x))) 
- #define MP make_pair 
- #define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i) 
- #define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i) 
- #define CLR(x,y) memset(x,y,sizeof(x)) 
- #define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end()) 
- #define MIN(a,b) ((a)<(b)?(a):(b)) 
- #define MAX(a,b) ((a)>(b)?(a):(b)) 
- #define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1) 
- #define SQ(x) ((x)*(x)) 
- #define ABS(x) ((x)<0?-(x):(x)) 
- #define FABS(x) ((x)+eps<0?-(x):(x)) 
- #define ALL(x) (x).begin(),(x).end() 
- #define LCM(x,y) (((x)/gcd((x),(y)))*(y)) 
- #define SZ(x) ((vlong)(x).size()) 
- #define NORM(x) if(x>=mod)x-=mod; 
-   
- using namespace std; 
-   
- typedef long long vlong; 
- typedef vector<int> vi; 
-   
- const vlong inf = 2147383647; 
- const double eps = 1e-11; 
-   
- struct polygon { 
-     vlong h; 
-     double x, y; 
-   
-     void init ( vlong _h ) { 
-         h = _h; 
-         calcY(); 
-         calcX(); 
-     } 
-     void calcY (){ 
-         y = h / ( 2 + sqrt ( 2 ) ); 
-     } 
-     void calcX() { 
-         x = sqrt ( 2 * y * y ); 
-     } 
- }pol[10]; 
-   
- vi arr; 
-   
- double center[10]; 
-   
- int main () { 
-     int kase, cnt = 0; 
-     scanf ( "%d", &kase ); 
-   
-     while ( kase-- ) { 
-         int n; 
-         scanf ( "%d", &n ); 
-   
-         arr.clear(); 
-   
-         double mxh = -1; 
-         FOR(i,0,n-1){ 
-             arr.pb ( i ); 
-             int t; 
-             scanf ( "%d", &t ); 
-             pol[i].init(t); 
-             if ( t > mxh ) mxh = t; 
-         } 
-   
-         double res = inf * inf; 
-   
-         do { 
-             double curWidth = 0; 
-             curWidth = pol[arr[0]].y * 2 + pol[arr[0]].x; 
-             center[0] = curWidth / 2; 
-   
-             FOR(iron,1,n-1){ ///Try to fit this polygon as close as possible 
-                 ///Try to push center of this pol near a pol, then check for conflict 
-                 int b = arr[iron]; 
-                 center[iron] = ( pol[b].y * 2 + pol[b].x ) / 2; ///Empty 
-                 FOR(joker,0,iron-1){ 
-                     int a = arr[joker]; 
-                     if ( pol[a].h > pol[b].h + eps && pol[a].y > pol[b].y + pol[b].x + eps ) { 
-                         ///A is bigger than B 
-                         double d = 2 * pol[b].y + 1.5 * pol[b].x; 
-                         double probableCenter = center[joker] + pol[a].x / 2 + d; 
-   
-                         if ( probableCenter > center[iron] + eps ) { 
-                             center[iron] = probableCenter; 
-                         } 
-                     } 
-                     else if ( pol[b].h > pol[a].h + eps && pol[b].y > pol[a].y + pol[a].x + eps ) { 
-                         ///B is bigger than A 
-   
-                         double d = pol[a].x / 2 + pol[a].y + pol[a].x + pol[a].y + pol[b].x / 2; 
-                         double probableCenter = center[joker] + d; 
-   
-                         if ( probableCenter > center[iron] + eps ) { 
-                             center[iron] = probableCenter; 
-                         } 
-                     } 
-                     else { 
-                         double d = pol[a].x / 2 + pol[a].y + pol[b].y + pol[b].x / 2; 
-                         double probableCenter = center[joker] + d; 
-                         if ( probableCenter > center[iron] + eps ) { 
-                             center[iron] = probableCenter; 
-                         } 
-                     } 
-                 } 
-                 double tempWidth = center[iron] + pol[b].x / 2 + pol[b].y; 
-                 if ( tempWidth > curWidth + eps ) curWidth = tempWidth; 
-             } 
-   
-             double vol = 8 * mxh * curWidth; 
-   
-             if ( vol + eps < res ) res = vol; 
-         }while ( next_permutation ( ALL(arr) ) ); 
-   
-         printf ( "Case %d: %.10lf\n", ++cnt, res + eps ); 
-     } 
-   
-     return 0; 
- } 
-