You are given an array A containing positive integers (1 <= A[i] <= 10^9)
The array score is calculated based on the following algorithm:
Example:
if A = [1,2,3]
after applying algorithm 1st time A = [3,3] (a1=1 and a2=2)
in next iteration A = [0] (a1=3 and a2=3) so score is 0 which is maximumum possible in this case hence answer is 0
another example if A = [1,2] answer = 3
How to solve this question or how to proceed with such questions?
Code in javascript would be helpful, but other languages are also welcome.