#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline double ABS(double a){return max(a,-a);}
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double ABS() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
int iSP(Pt a, Pt b, Pt c) {
	int s = sig((b - a).det(c - a));
	if (s) return s;
	if (sig((b - a).dot(c - a)) < 0) return -2; // c-a-b
	if (sig((a - b).dot(c - b)) < 0) return +2; // a-b-c
	return 0;
}
int iLL(Pt a, Pt b, Pt c, Pt d) {
	if (sig((b - a).det(d - c))) return 1; // intersect
	if (sig((b - a).det(c - a))) return 0; // parallel
	return -1; // correspond
}
bool iSS(Pt a, Pt b, Pt c, Pt d) {
	return (iSP(a, b, c) * iSP(a, b, d) <= 0 && iSP(c, d, a) * iSP(c, d, b) <= 0);
}
Pt pLL(Pt a, Pt b, Pt c, Pt d) {
	b = b - a; d = d - c; return a + b * (c - a).det(d) / b.det(d);
}
Pt p[110];
int it[110][110];
int ind[110][110];
Pt ip[110][110];
int t[110];
vector<int> g[12000];
vector<Pt> hb;
int add(Pt a){
	for(int i=0;i<hb.size();i++){
		if((a-hb[i]).ABS()<EPS)return i;
	}
	hb.push_back(a);
	return hb.size()-1;
}
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		double X,Y;
		scanf("%lf%lf",&X,&Y);
		p[i]=Pt(X,Y);
		t[i]=add(p[i]);
	}
	for(int i=0;i<a-1;i++){
		for(int j=0;j<a-1;j++){
			if(i==j)continue;
			if(iLL(p[i],p[i+1],p[j],p[j+1])>0&&iSS(p[i],p[i+1],p[j],p[j+1])){
				it[i][j]=1;
				ip[i][j]=pLL(p[i],p[i+1],p[j],p[j+1]);
				ind[i][j]=add(ip[i][j]);
			}
		}
	}
	int sz=hb.size();
	for(int i=0;i<a-1;i++){
		vector<pair<double,int> > tmp;
		tmp.push_back(make_pair(0,t[i]));
		tmp.push_back(make_pair((p[i+1]-p[i]).ABS(),t[i+1]));
		for(int j=0;j<a-1;j++){
			if(!it[i][j])continue;
			tmp.push_back(make_pair((ip[i][j]-p[i]).ABS(),ind[i][j]));
		}
		std::sort(tmp.begin(),tmp.end());
		for(int j=0;j<tmp.size()-1;j++){
			if(tmp[j].second==tmp[j+1].second)continue;
			g[tmp[j].second].push_back(tmp[j+1].second);
			g[tmp[j+1].second].push_back(tmp[j].second);
		}
	}
	double ret=0;
	int start=0;
	for(int i=1;i<sz;i++){
		if(hb[start].x>hb[i].x)start=i;
	}
	int at=start;
	Pt vec=Pt(0,-1);
	while(1){
		int to=-1;
		double val=9999999;
		double curth=vec.arg();
		for(int i=0;i<g[at].size();i++){
			double th=(hb[g[at][i]]-hb[at]).arg()-curth;
			if(th>PI+EPS)th-=2*PI;
			if(th<-PI+EPS)th+=2*PI;
			if(val>th){
				val=th;
				to=g[at][i];
			}
		}
		vec=hb[to]-hb[at];
		ret+=hb[at].det(hb[to]);
		at=to;
		if(at==start)break;
	}
	printf("%.12f\n",ABS(ret)/2);
}

Measured memory_bytes: 1848