Do you know what MSIS is? MSIS is the abbreviation for Maximum Sum Increasing Subsequence. It is a subsequence of a given list of integers, whose sum is maximum and in the subsequence, all elements are sorted in strictly increasing order.
Given an array of positive integers. Write a program to find the sum of the elements of the MSIS.
N.B: A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
First line of the input will contain an integer (), the number of elements in the array (). The second line will contain space separated integers, the elements of the array .
Print the sum of the elements of the MSIS of the given array .
3 5 1 3
All increasing subsequences have been listed below:
Sequence: , Sum: 5
Maximum sum is 5. So, the sum of the elements of the MSIS is 5.
5 8 54 17 58 45