#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void solve() {
  string s;
  cin >> s;
  long long ans = 0;
  long long curr = 0;
  unordered_map<long long, long long> mp;
  for (long long i = 0; i < s.length(); i++) {
    if (s[i] == '-')
      curr--;
    else
      curr++;
    if (curr < 0 && mp[curr] == 0) {
      mp[curr] = 1;
      ans += (i + 1);
    }
  }
  ans += (s.length());
  cout << ans << endl;
}
int32_t main() {
  c_p_c();
  long long t = 1;
  cin >> t;
  while (t--) solve();
}
