408224: GYM103059 E Even Subarrays
Description
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?
InputThe 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$$$.
OutputOutput a single integer giving the number of even subarrays of the array $$$a$$$.
ExampleInput6 1 1 3 3 2 2Output
6Note
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.