Computing Maximum value when element at index i and index j is to be choosed .
$ dp [ $ low ] [ $ high ] = max ( $ a [ $ low ] * $ turn + solve ( $ dp , $ a , $ low + 1 , $ high , $ turn + 1 ) , $ a [ $ high ] * $ turn + solve ( $ dp , $ a , $ low , $ high - 1 , $ turn + 1 ) ) ; return $ dp [ $ low ] [ $ high ] ; }