#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  vector<long long> v;
  long long f = 0;
  long long res = 0;
  long long k = 0;
  for (long long i = 0; i < s.length(); i++) {
    if (s[i] == '-')
      f--;
    else
      f++;
    v.push_back(f);
  }
  for (long long i = 0; i < s.length(); i++) {
    if (k + v[i] < 0) {
      k++;
      res = res + i + 1;
    }
  }
  cout << res + s.length() << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
}
