#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 20;
long long t, ss, dp[MAXN];
string s;
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> t;
  while (t--) {
    long long cnt = 0, ans = 0;
    cin >> s, ss = s.size();
    for (int i = 1; i <= ss; i++)
      dp[i] = dp[i - 1] + (s[i - 1] == '+' ? 1 : -1);
    for (int i = 1; i <= ss; i++)
      if (dp[i] - cnt < 0) ans += i, cnt--;
    cout << ans + ss << '\n';
  }
  return 0;
}
