#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<char> c(n - 1);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    if (i < n - 1) cin >> c[i];
  }
  vector<long long> cumsum(n + 1), sum(n + 1);
  for (int i = 0; i < n; ++i) cumsum[i + 1] = cumsum[i] + a[i];
  sum[0] = a[0];
  for (int i = 0; i < n - 1; ++i) {
    if (c[i] == '+')
      sum[i + 1] = sum[i] + a[i + 1];
    else
      sum[i + 1] = sum[i] - a[i + 1];
  }
  long long ans = sum[n - 1];
  vector<int> neg;
  for (int i = 0; i < n - 1; ++i)
    if (c[i] == '-') neg.push_back(i);
  cout << neg.size() << endl;
  for (int k = 0; k < (int)neg.size() - 1; ++k) {
    int x = neg[k], y = neg[k + 1];
    long long tmp =
        sum[x] - (cumsum[y + 1] - cumsum[x + 1]) + cumsum[n] - cumsum[y + 1];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
