#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  long long int ans = 0, count = 0, res = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '+') {
      count++;
    } else {
      count--;
      if (count < 0) {
        count = 0;
        res += (i + 1);
      }
    }
  }
  cout << res + s.length() << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
