To display the result
int ans = - 1 ; ArrayList < Boolean > chosen = new ArrayList < Boolean > ( Collections . nCopies ( N , false ) ) ; ans = getMax ( arr , ans , chosen , N ) ; System . out . print ( ans + "NEW_LINE"); } }