# HackerEarth Help Fredo problem solution

In this HackerEarth Help, Fredo problem solution Fredo is assigned a task today. He is given an array A containing N integers. His task is to update all elements of array to some minimum value x, that is, A[i] = x; 1 <= 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. Note that x should be as minimum as possible such that it meets the given condition. Help him find the value of x.

## HackerEarth Help Fredo with problem solution.

`#include<bits/stdc++.h>#define ll long long#define ld long doubleusing namespace std;ll a[100005];int n;int main(){    cin>>n;    for(int i=0;i<n;i++)    {        cin>>a[i];        assert(a[i]>=1 && a[i]<=1e10);    }    sort(a,a+n);    ld val=0;        for (int i=0;i<n;i++)                val+= (ld)(log((ld)(a[i])));        ll left=a[0],right=a[n-1]+1,ans;        while(left<=right)        {                ll mid=(left+right)/2;                ld temp= (ld)n * (ld)(log((ld)(mid)));                if(val < temp)                {            ans=mid;            right=mid-1;        }                else            left=mid+1;        }       cout<<ans<<"\n";    return 0;}`