import java.util.*;
public class Main {
public int solution(int[] input,int n) {
return method2(input);
}
public int method1(int[] array){
if(array == null || array.length ==0){
return 0;
}
int max = array[0];
int total = array[0];
for(int i=1;i<array.length;i++){
if(total>=0){
total += array[i];
}else{
total = array[i];
}
if(max < total){
max = total;
}
}
return max;
}
public int method2(int[] array){
int total = array[0];
for(int i=1;i<array.length;i++){
array[i] += array[i-1] > 0 ? array[i-1] : 0;
total = Math.max(total,array[i]);
}
return total;
}
}