#include <bits/stdc++.h>
using namespace std;
long long solve() {
  string s;
  cin >> s;
  long long res = 0;
  long long sum = 0;
  for (int i = 0; i < s.size(); ++i) {
    res++;
    if (s[i] == '-')
      --sum;
    else
      ++sum;
    if (sum < 0) {
      res += i + 1;
      ++sum;
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) cout << solve() << '\n';
  return 0;
}
