import java.util.*;
import java.lang.*;

public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param array int整型一维数组 
     * @return int整型一维数组
     */
    public int[] FindGreatestSumOfSubArray (int[] array) {
        // write code here
        int cur = 0;
        int max = Integer.MIN_VALUE,left = 0,right = 0;
        for(int i = 0;i < array.length;i++){
            cur += array[i];
            if(max <= cur){
                max = cur;
                right = i;
            }
            if(cur < 0){
                cur = 0;
                left = i + 1;
                
            }
        }
        int[] res;
        if(left > right){
            res = new int[]{array[right]};
        }else{
            res = new int[right-left+1];
            int j = 0;
            for(int i = left;i<=right;i++){
                res[j++] = array[i];
            }
        }
        return res;

    }
}