I found an interesting problem on https://www.codechef.com/problems/EAREA:
You are given a convex polygon $P$ with vertices $P_0, P_1, \ldots, P_{n-1}$, each having integer coordinates. On each edge $P_{i} P_{(i+1) \% n}$ of the polygon, choose a point $R_i$ uniformly at random. What is the expected area of the convex hull of these $n$ chosen points $R_0, R_1, \ldots R_{n-1}$ ?

-----Note-----
- Consider the area of the convex hull as zero if it contains less than 3 vertices.
- All the points $R_i$ are chosen independently of each other.
- Your answer is considered correct if and only if its absolute or relative error doesn't exceed $10^{-6}$.

-----Input-----
- The first line contains $n$, the number of vertices in the convex polygon.
- The next $n$ lines contain the coordinates of the vertices of the polygon in anti-clockwise order. 

-----Output-----
For each testcase, print the expected area of the convex hull of the $n$ randomly chosen points.

-----Constraints-----
- $3 \leq n \leq 10^5$
- The absolute values of all the coordinates $\leq 10^7$.
- All the points in the input are distinct.
- The described polygon $P$ is convex and the vertices of the polygon are given in anti-clockwise order. Also, no three vertices of the polygon are collinear.

-----Example Input-----
3
0 0
1 0
0 1

-----Example Output-----
0.1250000000

I tried it in Python, but could not do it. Can you solve it?
# cook your dish here
def func(a,n):
 if n < 3:
  return 0
 res_arr = []
 for i in range(n):
  x = (a[i][0] + a[(i + 1) % n][0]) / 2
  y = (a[i][1] + a[(i + 1) % n][1]) / 2
  res_arr.append((x, y))
 l = len(res_arr)
 s = 0
 for i in range(n):
  u = res_arr[i][0]*res_arr[(i+1) % l][1]
  v = res_arr[i][1]*res_arr[(i+1) % l][0]
  s += (u-v)
 return abs(s)/2

def __starting_point():
 n = int(input())
 arr = []
 for i in range(n):
  x, y = map(int, input().split())
  arr.append((x,y))
 
 res = func(arr, n)
 print(res)
__starting_point()