#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  string str;
  for (int i = 0; i < t; i++) {
    cin >> str;
    long long int res = 0;
    long long int arr[str.size()];
    if (str[0] == '+') {
      arr[0] = 1;
    } else {
      arr[0] = -1;
    }
    for (int j = 1; j < str.size(); j++) {
      if (str[j] == '+') {
        arr[j] = arr[j - 1] + 1;
      } else {
        arr[j] = arr[j - 1] - 1;
      }
    }
    int x = -1;
    for (int j = 0; j < str.size(); j++) {
      if (arr[j] == x) {
        res = res + j + 1;
        x--;
      }
    }
    res = res + str.size();
    cout << res << endl;
  }
  return 0;
}
