import
java.io.*;
class
GFG {
static
int
maxSubArraySum(
int
a[],
int
size)
{
int
max_so_far = Integer.MIN_VALUE, max_ending_here =
0
;
for
(
int
i =
0
; i < size; i++) {
max_ending_here = max_ending_here + a[i];
if
(max_so_far < max_ending_here)
max_so_far = max_ending_here;
if
(max_ending_here <
0
)
max_ending_here =
0
;
}
return
max_so_far;
}
static
int
maxSum(
int
a[],
int
n)
{
int
S =
0
;
int
S1 = maxSubArraySum(a, n);
for
(
int
i =
0
; i < n; i++)
S += a[i];
return
(
2
* S1 - S);
}
public
static
void
main (String[] args) {
int
a[] = { -
35
,
32
, -
24
,
0
,
27
, -
10
,
0
, -
19
};
int
n = a.length;
System.out.println( maxSum(a, n));
}
}