#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
const long double eps=1.0e-8;
const double pi=acos(-1.0);
int sgn(long double x)
{
    if(fabs(x)<eps) return 0;
    else return x<0?-1:1;
}
struct point
{
    long double x,y;
    point(long double  _x=0,long double  _y=0):x(_x),y(_y){};
    point operator + (point a) {return point(x+a.x, y+a.y);}
    point operator - (point a) {return point(x-a.x, y-a.y);}
    point operator * (long double  p) {return point(x*p, y*p);}
    point operator / (long double  p) {return point(x/p, y/p);}
    bool operator == (point a) {return sgn(x-a.x)==0&&sgn(y-a.y)==0;}
    bool operator < (const point a) const {return (sgn(x-a.x)<0) || ((sgn(x-a.x)==0)&&(sgn(y-a.y)<0));}
};
typedef point Vector;
long double  dmult(Vector a,Vector b) {return a.x*b.x+a.y*b.y;}
long double  xmult(Vector a,Vector b) {return a.x*b.y-a.y*b.x;}
long double Length(Vector a) {return sqrt(a.x*a.x+a.y*a.y);}
long double dis(point a,point b) {return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
long double angle(Vector v) {return atan2(v.y,v.x);}
long double RelativeAngle(Vector v,Vector u)
{
    long double c=dmult(v,u)/Length(v)/Length(u);
    if(c>1) c=1;
    else if(c<-1) c=-1;
	long double angle=acos(c);
	if(xmult(v,u)<0) angle=2*pi-angle;
	return angle;
}
bool SegmentProperIntersection(point a1,point a2,point b1,point b2)
{
    long double c1=xmult(a2-a1,b1-a1);
    long double c2=xmult(a2-a1,b2-a1);
    long double c3=xmult(b2-b1,a1-b1);
    long double c4=xmult(b2-b1,a2-b1);
    return sgn(c1)*sgn(c2)<0&&sgn(c3)*sgn(c4)<0;
}
point GetLineIntersection(point p,Vector v,point q,Vector w)
{
    Vector u=p-q;
    long double t=xmult(w,u)/xmult(v,w);
    return p+v*t;
}
bool OnSegment(point p,point a1,point a2)
{
    return sgn(xmult(a1-p,a2-p))==0&&sgn(dmult(a1-p,a2-p))<=0;
}

point s[105];
vector<point>p;
vector<vector<pair<int,int> > >G;
vector<bool>vis;
int sz=0;
int main ()
{
    //freopen("in.txt","r",stdin);
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;++i)
    {
        double x,y;
        scanf("%lf%lf",&x,&y);
        s[i].x=x;
        s[i].y=y;
        p.push_back(s[i]);
    }
	for(int i=0;i<N-1;++i)
	{
		point a1=s[i],a2=s[i+1];
		for(int j=i+1;j<N-1;++j)
		{
		    point b1=s[j],b2=s[j+1];
			if(SegmentProperIntersection(a1,a2,b1,b2)) p.push_back(GetLineIntersection(a1,a2-a1,b1,b2-b1));
		}
	}
	sort(p.begin(),p.end());
	p.erase(unique(p.begin(),p.end()),p.end());
	G.resize(p.size());
	for(int i=0;i<N-1;++i)
	{
	    point a1=s[i],a2=s[i+1];
		vector< pair<long double,int> >tmp;
		for(int j=0;j<p.size();++j) if(OnSegment(p[j],a1,a2)) tmp.push_back(make_pair(Length(p[j]-a1),j));
		sort(tmp.begin(),tmp.end());
		for(int j=0;j<tmp.size()-1;++j)
		{
			G[tmp[j].second].push_back(make_pair(tmp[j+1].second,0));
			G[tmp[j+1].second].push_back(make_pair(tmp[j].second,0));
		}
	}
	for(int i=0;i<p.size();++i)
	{
	    sort(G[i].begin(),G[i].end());
	    G[i].erase(unique(G[i].begin(),G[i].end()),G[i].end());
	    for(int j=0;j<G[i].size();++j) G[i][j].second=sz++;
	}
	vis.resize(sz,0);
	int from=0,to=G[0][0].first;
	for(int i=1;i<G[0].size();++i)
	{
		int v=G[0][i].first;
		if(angle(p[v]-p[0])<angle(p[to]-p[0])) to=v;
	}
	long double area=0;
	do
	{
		int nto=from,idx=0,fromidx=0;
		long double angle=1e9;
		for(int i=0;i<G[to].size();++i)
		{
			int v=G[to][i].first;
			if(v==from)
			{
				fromidx=G[to][i].second;
				continue;
			}
			if(vis[G[to][i].second]) continue;
			long double nangle=RelativeAngle(p[from]-p[to],p[v]-p[to]);
			if(nangle<angle)
			{
				nto=v;
				angle=nangle;
				idx=G[to][i].second;
			}
		}
		if(nto==from) idx=fromidx;
		if(vis[idx]) while(1);
		vis[idx]=true;
		area+=xmult(p[from],p[to])/2;
		from=to;
		to=nto;
	}while(from);
	printf("%.10f\n",(double)area);
    return 0;
}

Measured memory_bytes: 1476