#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    vector<long long int> v;
    long long int n = s.size(), cur = 0, a = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] == '+')
        cur++;
      else
        cur--;
      if (cur < a) {
        a = cur;
        v.push_back(i);
      }
    }
    long long int ans = 0, mx = abs(min(0LL, a));
    for (int i = 0; i < mx; ++i) {
      if (i < v.size()) ans += v[i] + 1;
    }
    ans += n;
    cout << ans << "\n";
  }
}
