class Solution {
public:
    int FindGreatestSumOfSubArray(vector<int> array) {
        int pre = 0;
        int sum = 0,res = INT_MIN;
        for(int i=0;i<array.size();i++){
            sum += array[i];
            res = max(res,sum-pre);
            pre = min(pre,sum);
        }
        
        return res;
    }
};