A duty roster lists n shifts on a timeline, each a closed range [start, end]. Shifts that overlap or touch join into blocks. Between two consecutive blocks there is an empty gap. Report the total length of all such internal gaps (the empty space strictly between the earliest merged block and the latest one). Space before the first block or after the last block does not count.
Input format
Line 1: an integer n.
Next n lines: two integers start and end describing one shift.
Output format
A single integer: the total internal gap length between merged blocks.
Constraints
- 1 ≤ n ≤ 100000
- 0 ≤ start ≤ end ≤ 1000000000