Maximum sum increasing sequence#

Given an array of n positive integers. Write a program to find the sum of maximum sum subsequence of the given array such that the integers in the subsequence are sorted in increasing order. For example, if input is {1, 101, 2, 3, 100, 4, 5}, then output should be 106 (1 + 2 + 3 + 100), if the input array is {3, 4, 5, 10}, then output should be 22 (3 + 4 + 5 + 10) and if the input array is {10, 5, 4, 3}, then output should be 10

def maxSumIS(arr):
    n = len(arr)
    max = 0
    msis = [0 for x in range(n)]
  
    for i in range(n):
        msis[i] = arr[i]
  
    for i in range(1, n):
        for j in range(i):
            if (arr[i] > arr[j] and
                msis[i] < msis[j] + arr[i]):
                msis[i] = msis[j] + arr[i]
  
    for i in range(n):
        if max < msis[i]:
            max = msis[i]
  
    return max
maxSumIS([1, 101, 2, 3, 100, 4, 5])
106