#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
const long long int mod = 1e9 + 7;
void solve() {
  string s;
  cin >> s;
  long long int ans = 0;
  long long int o = 0, z = 0;
  long long int k = 0;
  for (long long int i = 0; i < s.length(); i++) {
    if (s[i] == '-')
      o--;
    else
      o++;
    if (k > o) {
      ans = ans + i + 1;
      k = o;
    }
  }
  ans = ans + s.length();
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  cin >> t;
  while (t > 0) {
    solve();
    t--;
  }
  return 0;
}
