Problem D: Exportation in Space

In an era of space travelling, Mr. Jonathan A. Goldmine exports a special material named "Interstellar Condensed Powered Copper". A piece of it consists of several spheres floating in the air. There is strange force affecting between the spheres so that their relative positions of them are not changed. If you move one of them, all the others follow it.

<image>
Example of ICPC (left: bare, right: shielded)

To transport ICPCs between planets, it needs to be shielded from cosmic rays. It will be broken when they hit by strong cosmic rays. Mr. Goldmine needs to wrap up each ICPC pieces with anti-cosmic-ray shield, a paper-like material which cuts all the cosmic rays. To save cost, he wants to know the minimum area of the shield he needs to wrap an ICPC piece up.

Note that he can't put the shield between the spheres of an ICPC because it affects the force between the spheres. So that the only way to shield it is to wrap the whole ICPC piece by shield.

Mr. Goldmine asked you, an experienced programmer, to calculate the minimum area of shield for each material.

You can assume that each sphere in an ICPC piece is a point, and you can ignore the thickness of the shield.



Input

Each file consists of one test case, which has the information of one ICPC piece. A test case starts with a line with an integer N (4 <= N <= 50), denoting the number of spheres in the piece of the test case. Then N lines follow. The i-th line of them describes the position of the i-th sphere. It has 3 integers xi, yi and zi (0 <= x, y, z <= 100), separated by a space. They denote the x, y and z coordinates of the i-th sphere, respectively.

It is guaranteed that there are no data all of whose spheres are on the same plane, and that no two spheres in a data are on the same coordinate.

Output

For each input, print the area of the shield Mr. Goldmine needs. The output value should be in a decimal fraction and should not contain an error greater than 0.001.

Examples

Input

4
0 0 0
0 0 1
0 1 0
1 0 0


Output

2.366


Input

8
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1


Output

6.000
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

double getarea(const VP &poly){
    double ret = 0;
    for (int i=0; i<(int)poly.size(); i++){ 
        ret += cross(poly[i], poly[(i+1)%poly.size()]);
    }
    return ret*0.5;
}
VP convex(VP v){
    VP ret;
    int n = v.size();
    sort(v.begin(), v.end());
    for(int i=0; i<n; i++){
        while((int)ret.size()>1 && cross(ret.back()-ret[ret.size()-2], v[i]-ret.back()) < EPS){
            ret.pop_back();
        }
        ret.push_back(v[i]);
    }
    int t = ret.size();
    for(int i=n-2; i>=0; i--){
        while((int)ret.size()>t && cross(ret.back()-ret[ret.size()-2], v[i]-ret.back()) < EPS){
            ret.pop_back();
        }
        ret.push_back(v[i]);
    }
    if((int)ret.size() > 1) ret.pop_back();
    return ret;
}

struct Point{
    double x,y,z;
    Point(double x, double y, double z):x(x), y(y), z(z){}
    Point(){}
    Point &operator +=(const Point &a){ x+=a.x; y+=a.y; z+=a.z; return *this; }
    Point &operator -=(const Point &a){ x-=a.x; y-=a.y; z-=a.z; return *this; }
    Point &operator *=(const double &a){ x*=a; y*=a; z*=a; return *this; }
    Point operator +(const Point &a) const{ return Point(x+a.x, y+a.y, z+a.z); }
    Point operator -(const Point &a) const{ return Point(x-a.x, y-a.y, z-a.z); }
    Point operator *(const double &a) const{ return Point(a*x, a*y, a*z); }
    Point operator -() { return Point(-x, -y, -z); }
};
 
double dot(const Point &a, const Point &b){
    return a.x*b.x +a.y*b.y +a.z*b.z;
}
Point cross(const Point &a, const Point &b){
    return Point(a.y*b.z -a.z*b.y, a.z*b.x -a.x*b.z, a.x*b.y -a.y*b.x);
}
double abs(const Point &a){
    return sqrt(dot(a, a));
}
Point unit(const Point &a){
    return a *(1/abs(a));
}
bool operator ==(const Point &a, const Point &b){
    return abs(a-b) < EPS;
}

//2次元に転写して凸包の面積を出す
double convex_area(const vector<Point> &p, Point normal){
    VP p2d;
    Point base = p[1] -p[0];
    p2d.emplace_back(0, 0);
    p2d.emplace_back(abs(base), 0);
    for(int i=2; i<(int)p.size(); i++){
        Point v = p[i] -p[0];
        double theta = acos(dot(base, v)/(abs(base)*abs(v)));
        if(dot(cross(base, v), normal) > 0){
            theta *= -1;
        }
        p2d.push_back(P(abs(v), 0) *P(cos(theta), sin(theta)));
    }
    return getarea(convex(p2d));
}

int main(){
    int n;
    cin >> n;
    vector<Point> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i].x >> p[i].y >> p[i].z;
    }

    bool used[50][50][50];
    memset(used, false, sizeof(used));
    double ans = 0;
    //点を3つ選ぶ
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(used[i][j][k]) continue;
                Point normal = cross(p[j]-p[i], p[k]-p[i]);
                if(abs(normal) < EPS) continue;
                //同じ平面上の点を列挙
                vector<int> onplane, nop;
                for(int l=0; l<n; l++){
                    if(l==i || l==j || l==k || abs(dot(normal, p[l] -p[i])) < EPS){
                        onplane.push_back(l);
                    }else{
                        nop.push_back(l);
                    }
                }
                int m = onplane.size();
                for(int s=0; s<m; s++){
                    for(int t=s+1; t<m; t++){
                        for(int u=t+1; u<m; u++){
                            used[onplane[s]][onplane[t]][onplane[u]] = true;
                        }
                    }
                }
                //平面に対してすべて同じ方向にあるかどうか
                int sign = 0;
                for(int s=0; s<(int)nop.size(); s++){
                    double d = dot(normal, p[nop[s]] -p[i]);
                    if((sign==1 && d<0) || (sign==-1 && d>0)){
                        sign = 0;
                        break;
                    }
                    if(d > 0) sign = 1;
                    else sign = -1;
                }
                if(sign != 0){
                    vector<Point> plist;
                    for(int i=0; i<(int)onplane.size(); i++){
                        plist.push_back(p[onplane[i]]);
                    }
                    ans += convex_area(plist, normal);
                }
            }
        }
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}
