#include <bits/stdc++.h>
int main() {
  size_t n;
  std::cin >> n;
  std::string line;
  long long res;
  long long cnt, bottom;
  long long j;
  for (size_t i = 0; i < n; ++i) {
    std::cin >> line;
    res = cnt = bottom = 0;
    for (j = 0; j < line.size(); ++j) {
      cnt = (line[j] == '-') ? cnt - 1 : cnt + 1;
      if (cnt < bottom) {
        res += j + 1;
        bottom = cnt;
      }
    }
    std::cout << res + j << std::endl;
  }
  return 0;
}
