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