public static int[] getMaxSumSequence(int[] a) {
        if (a == null || a.length == 0) return null;

        int start = 0, end = 0, sum = 0;
        int[] ret = {0, 0, Integer.MIN_VALUE};
        for (int i = 0; i < a.length; ++i) {
            sum += a[i];
            end = i;
            if (sum > ret[2]) {
                ret[0] = start;
                ret[1] = end;
                ret[2] = sum;
            }
            if (sum < 0) {
                sum = 0;
                start = i + 1;
            }
        }
        return ret;
    }