#include <bits/stdc++.h>
using namespace std;
const int inf = 1e6 + 2;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> pos;
    int sum = 0;
    int mn = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '-')
        sum--;
      else
        sum++;
      if (sum < mn) {
        pos.push_back(i + 1);
        mn = sum;
      }
    }
    long long ans = 0;
    for (int i = 0; i < pos.size(); i++) {
      ans = ans + (long long)pos[i];
    }
    ans += n;
    cout << ans << endl;
  }
  return 0;
}
