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