Function to find the maximum element
static int getMax ( int [ ] arr , int n , int k ) { int res = int . MinValue ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] % k == 0 ) { res = Math . Max ( res , arr [ i ] ) ; } } return res ; }