Company: Visa_30_Dec
Difficulty: easy
Array Reduction by Leftmost Non-Zero Element You are given an array numbers of non-negative integers. Reduce it with the following algorithm and report the total it produces. Find the index i of the leftmost non-zero element and let x = numbers[i] . If every element is zero, the algorithm is over. Walk right from index i . At each position: - if the element is strictly less than x , the walk ends — go to step 3; - otherwise subtract x from it and move to the next position; - if you run past the end of the array, the walk ends — go to step 3. 3. Add x to the result. 4. Go back to step 1. Report the sum of all the values x added in step 3. Input Format The first line contains one integer n — the length of the array. The second line contains n space-separated integers numbers[0], numbers[1], ..., numbers[n-1] . Output Format Print a single integer — the accumulated result. Constraints 1 <= n <= 100 0 <= numbers[i] <= 10^6 Each round adds at most 10^6 and there are at most n ro