Extract maximum element of the given array
int maxi = arr [ 0 ] ; for ( int i = 1 ; i < arr . length ; i ++ ) maxi = Math . max ( maxi , arr [ i ] ) ; ArrayList < Integer > primes = SieveOfEratosthenes ( maxi ) ; for ( int i = 0 ; i < n ; i ++ ) {