#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool mycomp(T x, T y) {
  return (x == y);
}
bool paircomp(const pair<long long int, long long int> &x,
              const pair<long long int, long long int> &y) {
  return x.second < y.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long int sumr = 0;
    long long int minr = 0;
    long long int cc = 0;
    for (long long int i = 0; i < (s).size(); i++) {
      if (s[i] == '-')
        cc--;
      else
        cc++;
      if (cc < minr) {
        minr = cc;
        sumr += (i + 1);
      }
    }
    sumr += (s).size();
    cout << sumr << '\n';
  }
}
