#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string a;
    cin >> a;
    int ans = 0;
    long long cnt = 0;
    for (int i = 0; i < a.size(); i++) {
      if (ans > 0 && a[i] == '-') {
        ans--;
        continue;
      }
      if (a[i] == '-') {
        ans--;
        if (ans < 0) cnt += i + 1;
        ans = 0;
      } else
        ans++;
    }
    cout << cnt + a.size() << '\n';
  }
}
