|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||2||2||2||100.000%|
You are participating in a ski race. It's rumored that an autograph of Serj Tankian is the grand prize.
Every racer must pass through $n$ gates numbered from 1 to $n$. The $i$-th gate consists of several equivalent checkpoints, which can be considered as points on a plane having coordinates $(i, j)$ for all integers $j$ between $l_i$ and $r_i$, inclusive. It's required to pass through exactly one checkpoint at every gate in increasing order of gate numbers.
Unfortunately, you are very bad at turning on skis. Thus, you would like to prepare a route for yourself which is a straight line passing through a single checkpoint at every gate. How many route options do you have?
The first line of the input contains a single integer $n$ ($2 \le n \le 2 \cdot 10^5$).
Each of the next $n$ lines contains two integers $l_i$ and $r_i$ ($1 \le l_i \le r_i \le 10^9$).
Output a single integer --- the number of valid straight routes you can take.
3 1 3 2 3 1 5
In the example test case, all possible routes are: