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