#include <bits/stdc++.h>
using namespace std;
long double pi = 3.14159;
set<long long> stp;
void power2() {
  for (int i = 0; i <= 28; i++) {
    long long k = (long long)(pow(2, i));
    stp.insert(k);
  }
}
long long fpower(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool prime[10000001];
void Sieve(int n) {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
void solve() {
  long long res = 0;
  string s;
  cin >> s;
  int curr = 0;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    res = res + 1;
    if (s[i] == '+')
      curr++;
    else
      curr--;
    if (curr < 0) {
      res += i + 1;
      curr = 0;
    }
  }
  cout << res << endl;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
