package main

import "math"
/**
 * 
 * @param array int整型一维数组 
 * @return int整型
*/
func FindGreatestSumOfSubArray( array []int ) int {
    // write code here
    if len(array) == 0 {
        return 0
    }

    max := math.MinInt64
    sum := 0

    for i:=0; i<len(array);i++{
        if sum < 0 {
            sum = array[i]
        }else{
            sum += array[i]
        }

        if sum > max {
            max = sum
        }
    }

    if max == math.MinInt64 {
        return 0
    }

    return max
}