#include <bits/stdc++.h>
using namespace std;
long long ans;
int a[100005][2];
long long sum1[100005], sum2[100005];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%d", &a[1][0]);
  sum1[1] = sum2[1] = a[1][0];
  for (int i = 1; i < n; ++i) {
    int x = 0;
    bool flag = false;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) flag |= (ch == '-');
    for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
    a[i + 1][0] = x;
    a[i + 1][1] = flag;
    sum1[i + 1] = sum1[i] + (flag ? -x : x);
    sum2[i + 1] = sum2[i] + x;
  }
  ans = sum1[n];
  for (int i = 1; i <= n; ++i)
    if (a[i][1]) ans = max(ans, sum1[i] + sum2[n] - sum2[i]);
  cout << ans << endl;
  return 0;
}
