Function to return the sum of elements in an array having prime frequency
static int sumOfElements ( int [ ] arr , int n ) { bool [ ] prime = new bool [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) prime [ i ] = true ; SieveOfEratosthenes ( prime , n + 1 ) ;