VirtualData has just found two binary set \(A_1, A_2, \cdots, A_n\) and \(B_1, B_2, \cdots, B_n\) (\(A_i, B_i ∈ \text{{0, 1}}\) for all \(1 \leq i \leq n\)) from his virtual machine! He would like to perform the operation described below exactly twice, so that \(A_i = B_i\) holds for all \(1 \leq i \leq n\) after the two operations.
The operation is: Select two integers \(l\) and \(r\) (\(1 \leq l \leq r \leq n\)), change \(A_i\) to \((1 - A_i)\) for all \(l \leq i \leq r\). VirtualData would like to know the number of ways to do so.
We use the following rules to determine whether two ways are different:
Input format
Output format
Print an integer in a new line, representing the number of unique ways given operation can be performed.
Constraints
\(1 \leq n \leq 10^6\)
In this case, we have the following options, (0 based indexing):
So, there are a total of 6 distinct ways to perform the operations and make both sequences identical, hence the output is 6.