There is a hidden array of N bits – a_0,…,a_N−1. In one query, you can choose a subset of positions in the sequence and flip the bits at those positions. Flipping a 0 bit changes it to a 1 and flipping a 1 bit turns it into a 0. After each query, you are given the length of the longest consecutive subarray of 1s in the new array. Such queries persist, i.e. a flipped bit from a previous query will stay flipped until flipped back.
You want to find where the longest subarray of onesin the array (or any one of them if multiple ones exist) is located after all queries. Write a program to do this in as few queries as possible.