#include <bits/stdc++.h>
using namespace std;
int func(string s) {
  int res = 0;
  for (long long int i = 0; i < 99999999999999; i++) {
    long long int cur = i;
    bool ok = true;
    for (int j = 0; j < s.length(); j++) {
      res++;
      if (s[j] == '+')
        cur++;
      else
        cur--;
      if (cur < 0) {
        ok = false;
        break;
      }
    }
    if (ok) break;
  }
  return res;
}
int main() {
  int t;
  cin >> t;
  for (int tt = 0; tt < t; tt++) {
    string s;
    cin >> s;
    int cminus = 0;
    long long int sum = 0;
    int k = 1;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == '+')
        cminus--;
      else
        cminus++;
      if (cminus > 0) {
        if (cminus >= k) {
          sum = sum + i + 1;
          k++;
        }
      }
    }
    sum = sum + s.length();
    cout << sum << endl;
  }
}
