#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  cin >> ws;
  for (long long i = 0; i < t; i++) {
    string s;
    cin >> s;
    long long p = s.size();
    long long c = 0;
    long long res = 0, f = 0;
    for (long long j = 0; j < p; j++) {
      if (s[j] == '-') {
        c = c - 1;
      }
      if (s[j] == '+') {
        c += 1;
      }
      if (c == -1) {
        f += j + 1;
        c = 0;
      }
    }
    cout << f + p << "\n";
  }
  return 0;
}
