We’re preparing your current view and syncing the latest data.
You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure: let x be the sum of all elements currently in arr. Choose index i, set arr[i] = x. You want to determine if it is possible to construct the target array from arr by applying this procedure any number of times.
An array of integers target.
Return true if it is possible to construct the target array, otherwise false.
1 <= target.length <= 5 * 10^4; 1 <= target[i] <= 10^9
Example 1
Input
[9,3,5]
Output
true
Explanation
Start from [1,1,1]. Sum is 3. Replace element at index 0 with 3 to get [3,1,1]. Sum is 5. Replace element at index 0 with 5 to get [5,1,1]. Sum is 7. Replace element at index 0 with 7 to get [7,1,1]. Sum is 9. Replace element at index 1 with 9 to get [7,9,1]. Sum is 17. Replace element at index 2 with 17 to get [7,9,17]. Not matching target; check process or alternative reversing steps.