Minimum value product
Submissions: 191   Accuracy:

36.65%

  Difficulty: Easy   Marks: 2

Given an array of n elements, update all elements of given array to some minimum value x i.e, arr[i] = x (0 <= i < n), such that product of all elements of this new array is strictly greater than the product of all elements of the initial array.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the size of the array. The next line contains the space separated array elements.

Output:
Print the minimum value for the new array such that product of elements of this new array is strictly greater than the product of all elements of the initial array.

Constraints:
1<=T<=10^5
1<=arr[i]<=10^10
1<=n<=10^5

Example:
Input:

2
5
4 2 1 10 6
5
100 150 10000 123458 90980454

Output:
4
17592

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ayush Govil
Author: Ayush Govil 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.