#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long cur(0), mn(0), res(s.size());
    for (long long i = 0; i < s.size(); i++) {
      if (s[i] == '+')
        cur += 1;
      else
        cur -= 1;
      if (cur < mn) {
        mn = cur;
        res += i + 1;
      }
    }
    cout << res << "\n";
  }
  return (0);
}
