class Solution {

public:

```
int maxSubArray (int A[], int n) {
int max_sum=-INT_MAX, sum=0;
for (int i=0; i<n; ++i){
sum+=A[i];
sum=max(sum,A[i]);
if (sum>max_sum)
max_sum=sum;
}
return max_sum;
}
```

};