Function to return the maximum cost
function answer ( a , n ) { let dp = new Array ( size ) ; for ( let i = 0 ; i < size ; i ++ ) { dp [ i ] = new Array ( size ) ; for ( let j = 0 ; j < size ; j ++ ) { dp [ i ] [ j ] = - 1 ; } }