#include <stdio.h>
#include <stdlib.h>
int MaxSubsequenceSum(const int a[], int n)
{
int currentSum = 0;
int maxSum = 0;
for(int i = 0; i < n; i++)
{
currentSum += a[i];
if(currentSum > maxSum)
{
maxSum = currentSum;
}
if(currentSum < 0)
{
currentSum = 0;
}
}
return maxSum;
}
int main()
{
int a[7] = { 1,-2,3,-6,7,-2,5};
int b = MaxSubsequenceSum(a,7);
printf("%d\n",b);
system("pause");
return 0;
}