find the max sum of subsequence of array using DP