Bohdan against "tails"

Problem Author:Pavlo Tsitsei
Prepared by:Pavlo Tsitsei, Feysa Bohdan
Editorial by:Pavlo Tsitsei

The solution is to simulate the process described in the statement. That is, considering the element $$$i$$$, it is necessary to add to the answer $$$max(\lfloor \frac{x}{2^k}\rfloor ,1)$$$ where $$$k$$$ is the number of elements $$$j<i$$$ such that $$$a_i=a_j$$$.