408224: GYM103059 E Even Subarrays

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Even Subarraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Recently, Steven developed an obsession with all things even. Ever since that day, Steven has used level bars on all his tables and desks, refused to play two player games where either player has a winning strategy, and spent several hours thinking about functions like $$$x^2$$$ and $$$\cos(x)$$$.

However, Steven wants to cure himself of his even obsession and realizes the only way he can do so is to solve a competitive programming question related to even numbers. The question Steven wishes to solve is the following: given an array $$$a$$$, count the number of even subarrays of $$$a$$$. A subarray is even if each element inside the subarray appears exactly twice within the subarray.

Can you help Steven solve this problem?

Input

The first line of the input consists of a single integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5)$$$. The next line consists of $$$n$$$ space separated integers $$$a_i$$$ ($$$1 \leq a_i \leq n$$$), giving the elements of the array $$$a$$$.

Output

Output a single integer giving the number of even subarrays of the array $$$a$$$.

ExampleInput
6
1 1 3 3 2 2
Output
6
Note

In this example, any subarray that starts on an even index and ends on an odd index is an even subarray, and there are $$$6$$$ such arrays.

加入题单

上一题 下一题 算法标签: