#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  ios::sync_with_stdio(false);
  long long int T, a, b, i, t, k;
  cin >> T;
  while (T--) {
    cin >> s;
    t = 0;
    k = 0;
    for (i = 0; i < s.size(); i++) {
      if (k == 0 && s[i] == '-') {
        t = t + i + 1;
      } else if (s[i] == '-') {
        k--;
      } else {
        k++;
      }
    }
    cout << t + s.size() << "\n";
  }
}
