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