Company: Amazon Intern
Difficulty: medium
Sum of Array Peter has an integer array A of size N. He must perform the operations listed below: Update all the elements of array A with the GCD (Greatest Common Divisor) of A[i] and the largest element in the subarray A[i] to A[i]. After completing Operation 1, Peter must group the elements so that the largest element is grouped with smallest element and the second largest with second smallest and so on. Now he must find out the GCD of each group and insert their resultant value in a new array B. Your task is to help Peter find and return an integer value, representing the sum of array B, after completing all the above operations. Input Format input1 : An integer value N, representing the size of the array A. input2 : An integer array A. Output Format Return an integer value, representing the sum of array B. Constraints N is always even. The value of i ranges from 0 to N-1. Examples Example 1: input1: 4 input2: [1,14,11,19] Output: 2 Here, the given array A is [1,14,11,19]. The opera