Sum of the maximum downsequence number in an array
<p>Given this array</p>

<pre><code>int [] myArray = {5,-11,2,3,14,5,-14,2};
</code></pre>

<p>You are to find the maximum sum of the values in any downsequence in an unsorted array of integers. If the array is of length zero then maxSeqValue must return Integer.MIN_VALUE.</p>

<p>You should print the number, 19 because the downsequence with the maximum sum is 14,5.
Downsequence number is a series of non-increasing number.</p>

<p>These are the codes that i used but i guess that there are some cases which is still not accounted for.
Any ideas, thanks in advance.</p>

<pre><code>public class MaxDownSequence{
public int maxSeqValue(int[] a){
    int sum=Integer.MIN_VALUE;
    int maxsum=Integer.MIN_VALUE;
   for (int i=1;i&lt;a.length;i++){
        if(a[i]&lt;a[i-1]){
            sum = a[i] + a[i-1];
            if (sum&gt;maxsum){
                maxsum=sum;
            }
        }
        else {
            sum=a[i];
            if (sum&gt;maxsum){
                maxsum=sum;
            }
        }
   }
   if (a.length==0){
       return Integer.MIN_VALUE;
   }
   else{
       return maxsum;

   }
}
public static void main(String args[]){
    MaxDownSequence mySeq = new MaxDownSequence();
    int [] myArray = {5,-11,2,3,14,5,-14,2};
    System.out.println(mySeq.maxSeqValue(myArray));
}
</code></pre>

<p>}</p>
