A line $g$ is given in a plane. $n$ distinct points are chosen arbitrarily from $g$ and are named as $A_1, A_2, \ldots, A_n$. For each pair of points $A_i,A_j$, a semicircle is drawn with $A_i$ and $A_j$ as its endpoints. All semicircles lie on the same side of $g$. Determine the maximum number of points (which are not lying in $g$) of intersection of semicircles as a function of $n$.