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