#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long m = mod, c = 0, j = 0;
    for (int i = 0; i < (int)(((int)(s).size())); ++i) {
      if (s[i] == '-')
        c--;
      else
        c++;
      if (c < 0) {
        c = 0;
        j += i + 1;
      }
    }
    if (c >= 0) j += ((int)(s).size());
    cout << j << "\n";
  }
  return 0;
}
