package shuzu;
import java.util.Random;
public class shuzu {
public static void main(String[] args) {
int arr[]=new int[5];
Random ra=new Random();
for(int i=0;i<=4;i++){
int a=ra.nextInt(10);
int b=ra.nextInt(2);
if(b==1){
arr[i]=a;
}else {
arr[i]=-a;
}
System.out.print(arr[i]+",");
}
int i=arrmax(arr);
System.out.println(i);
}
public static int arrmax(int[] arr){
int n=arr.length;
int[]End=new int[n];
int[]All=new int[n];
End[n-1]=arr[n-1];
All[n-1]=arr[n-1];
End[0]=All[0]=arr[0];
for(int i=1;i<n;++i)
{
End[i]=Integer.max(End[i-1]+arr[i], arr[i]);
All[i]=Integer.max(End[i],All[i-1]);
}
return All[n-1];
}
}