- 35.48%
- 1000ms
- 262144K

There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( $x$ , $y$ ) means the wave is a rectangle whose vertexes are ( $0$ , $0$ ), ( $x$ , $0$ ), ( $0$ , $y$ ), ( $x$ , $y$ ). Every time the wave will wash out the trace of former wave in its range and remain its own trace of ( $x$ , $0$ ) -> ( $x$ , $y$ ) and ( $0$ , $y$ ) -> ( $x$ , $y$ ). Now the toad on the coast wants to know the total length of trace on the coast after n waves. It's guaranteed that a wave will not cover the other completely.

The first line is the number of waves $n(n \le 50000)$.

The next $n$ lines，each contains two numbers $x$ $y$ ,( $0 < x$ , $y \le 10000000$ )，the $i$-th line means the $i$-th second there comes a wave of ( $x$ , $y$ ), it's guaranteed that when $1 \le i$ , $j \le n$ ，$x_i \le x_j$ and $y_i \le y_j$ don't set up at the same time.

An Integer stands for the answer.

As for the sample input, the answer is $3+3+1+1+1+1=10$

3 1 4 4 1 3 3

10