#include <bits/stdc++.h>
using namespace std;
void print_vll(vector<long long>& arr) {
  for (long long i = 0; i < arr.size(); i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}
int main() {
  long long test;
  cin >> test;
  for (long long t = 0; t < test; t++) {
    string str;
    cin >> str;
    long long n = str.size();
    vector<long long> val(n);
    long long curDif = 0;
    for (long long i = 0; i < n; i++) {
      if (str[i] == '-')
        curDif++;
      else
        curDif--;
      val[i] = curDif;
    }
    vector<long long> stuck(n, 0);
    long long curMax = 0;
    for (long long i = 0; i < n; i++) {
      if (val[i] > curMax) {
        stuck[i] = val[i] - curMax;
        curMax = val[i];
      }
    }
    long long ans = n;
    for (long long i = 0; i < n; i++) {
      ans += (i + 1) * stuck[i];
    }
    cout << ans << endl;
  }
}
