import java.util.*;


public class Solution {
    /**
     * max sum of the subarray
     * @param arr int整型一维数组 the array
     * @return int整型
     */
    public int maxsumofSubarray (int[] arr) {
        // write code here
        if(arr.length >= 1){
            int maxNumber = arr[0];
            int sum = arr[0];
            for(int i = 1 ; i < arr.length ; i++){
                sum += arr[i];
                if(sum < 0){
                    sum = 0;
                }
                if(maxNumber < sum){
                    maxNumber = sum;
                }
            }
            return maxNumber;
        }
        return 0;
    }
}