#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  for (cin >> t; t; --t) {
    string s;
    cin >> s;
    long long n = s.length();
    long long negs = 0, pos = 0, sum = n;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '-') {
        negs++;
        if (negs > pos) {
          sum += (i + 1);
          pos++;
        }
      } else
        pos++;
    }
    cout << sum << endl;
  }
}
