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