using log property add every logarithmic value of element to val double val = 0 ; where double is long double
for ( int i = 0 ; i < n ; i ++ ) { val += ( double ) ( Math . log ( ( double ) ( arr [ i ] ) ) ) ; }