There are n slimes standing in a row, the ith one has size Ai. Merging two slimes of the same size i will result in a slime of size i+1.
Count the number of pairs l≤r that merging all slimes l,l+1,...,r results in one slime.
### Input
- The first line contains an integer n.
- The next line contains n integers Ai.
### Output
- Print the number of pairs.
### Constraints
- 1≤n≤105.
- 1≤Ai≤109.
### Example
Input:
3112
Output:
5