The Missing Cat Shortcut
Along a straight rooftop, cats stand at distinct positions , listed from left to right. Cat has jump power .
Cat can jump directly to cat on its right if and only if
A relay surprise is an ordered triple of indices satisfying for which:
- cat can jump directly to cat ;
- cat can jump directly to cat ; and
- cat cannot jump directly to cat .
Count the number of relay surprises.
Input
The first line contains an integer (), the number of cats.
The next lines describe the cats in left-to-right order. The -th of these lines contains two integers and (, ), the position and jump power of cat .
Output
Print one integer: the number of relay surprises.
Samples
Sample 1
Input
5 0 4 2 5 4 1 7 3 9 0
Output
2
The relay surprises are and .
Sample 2
Input
3 1 100 2 100 3 100
Output
0
Every earlier cat can jump directly to every later cat, so there are no relay surprises.