#include <bits/stdc++.h>
using namespace std;
void test_case() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> sum(n, 0);
  int current = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '+') {
      current += 1;
    } else {
      current -= 1;
    }
    sum[i] = current;
  }
  long long res = 0;
  int min = 0;
  for (int i = 0; i < n; ++i) {
    if (sum[i] < min) {
      min = sum[i];
      res += i + 1;
    }
  }
  res += n;
  cout << res << endl;
}
int main() {
  int tests;
  cin >> tests;
  for (int i = 0; i < tests; ++i) {
    test_case();
  }
  return 0;
}
