#P2785. Calculate Magnetic Flux

    ID: 16047 Type: Default 1000ms 256MiB

Calculate Magnetic Flux

Calculate Magnetic Flux

HansBug is presented with a strange magnetic field in the form of a polygon. The polygon is described by a sequence of NN points representing its vertices in order. The magnetic flux in this context is defined as the area of the polygon. You can compute the area using the shoelace formula:

$$\text{Area} = \frac{1}{2} \left| \sum_{i=1}^{N} \left( x_i y_{i+1} - x_{i+1} y_i \right) \right|, $$

where xN+1=x1x_{N+1}=x_1 and yN+1=y1y_{N+1}=y_1. Your task is to calculate and output the magnetic flux (i.e. the area) of the polygon.

inputFormat

The first line contains an integer NN (3N1053\leq N\leq 10^5), the number of vertices of the polygon. Each of the following NN lines contains two integers xx and yy (109x,y109-10^9\leq x,y\leq 10^9), which are the coordinates of the vertices given in order.

outputFormat

Output a single number, which is the magnetic flux (area) of the polygon. Print the result with one digit after the decimal point.

sample

4
0 0
4 0
4 3
0 3
12.0

</p>