#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  void solve() {
    string s;
    cin >> s;
    int cur = 0;
    long long res = 0;
    int offset = 0;
    for (int i = 0; i < s.length(); i++) {
      res++;
      if (s[i] == '+') {
        cur++;
      } else {
        cur--;
        if (cur + offset < 0) {
          res += i + 1;
          offset++;
        }
      }
    }
    cout << res << endl;
  }
};
int main(int argc, const char* argv[]) {
  int t;
  cin >> t;
  while (t--) {
    Solution sol;
    sol.solve();
  }
  return 0;
}
