#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int t;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    ll cnt = 0;
    string s;
    cin >> s;
    int tmp = 0;
    if (s[0] == '-')
      ++cnt, tmp = -1;
    else
      tmp = 1;
    for (int i = 1; i < s.size(); ++i) {
      if (s[i] == '+') {
        if (tmp < 0)
          tmp = 1;
        else
          ++tmp;
      } else {
        --tmp;
        if (tmp < 0) cnt += i + 1;
      }
    }
    cout << cnt + s.size() << '\n';
  }
}
