A Little Party Never Hurt Anybody
Axelle always wanted to be an adventurer. There are unique skills that each adventurer may possess. She entered the adventurers' guild and saw adventurers lined up. She realized that they were gathering a party to raid the boss. Each adventurer has their own value that denotes which special skills they possess:
initially every adventurer's value is equal to ;
for each skill with number that adventurer possesses, the number is added to his value.
A member of the party is considered to be useless if every other member of that party possesses all the skills that the useless member has. A party is considered to be bad if there is at least one useless member. A party of one member is always considered bad.
YYou are given the values of those n adventurers in the order that they are lined up in a form of array . The parties may be formed only out of one consecutive segment of an array.
Your only goal is to find out how many bad parties can be formed.
Input
The first line contains an integer — length of array .
The second line contains integers — values of each adventurer in line.
Output
Output a single integer — the number of bad parties that can be formed.
Examples
Note
In the example, the bad parties are:
in this party, the adventurer with value is considered useless (he possesses skill with number , whereas adventurer with value 3 possesses skills with numbers and )
in this party, the adventurer with value is considered useless (he possesses skill with number , whereas adventurer with value 5 possesses skills with numbers and )
Scoring
( points): ;
( points): ;
( points): ;
( points): no additional restrictions.