#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long res = 0, n = s.length(), curr = 0, pos = 0, neg = 0;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '-')
        neg++;
      else
        pos++;
      if (curr + pos - neg == -1) {
        res += i + 1;
        curr++;
      }
    }
    cout << res + n << "\n";
  }
  return 0;
}
