class Solution {
public:
    int FindGreatestSumOfSubArray(vector<int> array) {
        if (array.size() <= 0) return INT_MIN;
        int maxsum = array[0];
        for (size_t i  = 1; i < array.size(); ++ i) {
            array[i] += array[i-1] > 0 ? array[i-1] : 0;
            maxsum = max(array[i], maxsum);
        }
        return maxsum;
    }
};