In the adjacent figure the graphs of two function $y=f(x)$ and $y=\sin x$ are given. $y=\sin x$ intersects, $y=f(x)$ at $A(a, f(a)) ; B(\pi, 0)$ and $C(2 \pi, 0)$
$A_{i}(i=1,2,3)$ is the area bounded by the curves $y=f(x)$ and $y=\sin x$. between $x=0$ and $x=a ; i=1$
between $x=a$ and $x=\pi ; i=2$ between $x=\pi$ and $x=2 \pi ; i=3$. If $A_{1}=1-\sin a+(a-1) \cos a$, determine the function $f(x)$. Hence, determine $a$ and $A_{1}$. Also, calculate $A_{2}$ and $A_{3}$.