#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int r = 0, cur = 0, o, i, j, n;
    string s;
    cin >> s;
    n = s.size();
    for (i = 0; i < n; i++) {
      if (s[i] == '+')
        cur++;
      else
        cur--;
      if (cur < 0) {
        cur = 0;
        r += (i + 1);
      }
    }
    cout << r + n << endl;
  }
  return 0;
}
