#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long n = s.size();
    long long ind[n + 1];
    for (long long i = 1; i <= n; i++) {
      ind[i] = 0;
    }
    long long m = 0;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '-') {
        m--;
      } else {
        m++;
      }
      if (m < 0) {
        long long ab = abs(m);
        if (ind[ab] == 0) {
          ind[ab] = i + 1;
        }
      }
    }
    long long sum = 0;
    for (long long i = 1; i <= n; i++) {
      sum += ind[i];
    }
    sum += n;
    cout << sum << "\n";
  }
  return 0;
}
