public void solve() throws IOException {
    boolean start = true;
    while (start) {
      int n = nextInt();
      if (n == 0) {
        start = false;
        break;
      }

      int max = -101;
      int total = 0;
      for (int x = 0; x < n; x++) {
        total += nextInt();
        if (total > max)
          max = total;
        if (total < 0)
          total = 0;
      }
      System.out.println(max);
    }
  }