# Kadens Algo (最大子序列)

```java
    public long findMaxSum(int[] arr){
        long max = Integer.MIN_VALUE;
        long curMaxSum = 0;
        for(int i = 0; i < arr.length ; i++){
            curMaxSum = curMaxSum > 0 ? (curMaxSum + arr[i])%mod : arr[i];
            max = Math.max(max, curMaxSum);
        }
        return max > 0 ? max : 0;
    }
    
```
