#include <set>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10, INF = 1e18;

int ret[2] = {INF, 0};
int a[N], seg[N << 2][2];

void build(int i, int j, int n) {
  if (i == j) {
    seg[n][0] = seg[n][1] = a[i];
    return;
  }
  int m = (i + j) >> 1;
  build(i, m, n << 1);
  build(m + 1, j, n << 1 | 1);
  seg[n][0] = min(seg[n << 1][0], seg[n << 1 | 1][0]);
  seg[n][1] = max(seg[n << 1][1], seg[n << 1 | 1][1]);
}

int query(int i, int j, int l, int r, int n, bool b) {
  if (i > r || j < l) {
      return ret[b];
  }
  if (i >= l && j <= r) {
    return seg[n][b];
  }
  int m = (i + j) >> 1;
  if (b) {
    return max(query(i, m, l, r, n << 1, 1), query(m + 1, j, l, r, n << 1 | 1, 1));
  } else {
    return min(query(i, m, l, r, n << 1, 0), query(m + 1, j, l, r, n << 1 | 1, 0));
  }
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    build(0, n - 1, 1);
    int mx = 0;
    bool ok = 0;
    for (int i = 0; i + 2 < n; ++i) {
      mx = max(mx, a[i]);
      bool nope = 0;
      int l = i + 1, r = n - 2;
      while (l + 3 < r) {
        int m = (l + r) >> 1;
        int x = query(0, n - 1, i + 1, m, 1, 0);
        int y = query(0, n - 1, m + 1, n - 1, 1, 1);
        if (x < mx) {
          r = m - 1;
        } else if (x > mx) {
          l = m + 1;
        } else if (y < mx) {
          r = m - 1;
        } else if (y > mx) {
          l = m + 1;
        } else {
          l = m;
          break;
        }
      }
      while (l < n - 1 && l <= r) {
        int x = query(0, n - 1, i + 1, l, 1, 0);
        int y = query(0, n - 1, l + 1, n - 1, 1, 1);
        if (x == y && x == mx) {
          ok = 1;
          cout << "YES\n" << i + 1 << ' ' << l - i << ' ' << n - l - 1 << '\n';
          break;
        }
        ++l;
      }
      if (ok) {
        break;
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - 1 << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (l > 1 && r < n) {
        while (1) {
          int p = l, q = r;
          while (l > 2 && pre[l - 1] > mn) {
            mn = min(mn, a[--l]);
          }
          while (r < n - 1 && suf[r + 1] > mn) {
            mn = min(mn, a[++r]);
          }
          if (p - q == l - r) {
            break;
          }
        }
        if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          if (r == n - 1) {
            mn = min(mn, a[--l]);
          } else if (l == 2) {
            mn = min(mn, a[++r]);
          } else {
            if (a[l - 1] > a[r + 1]) {
              mn = a[--l];
            } else {
              mn = a[++r];
            }
          }
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - 1 << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (r < v.back()) {
        mn = min(mn, a[r++]);
      }
      while (l > 1 && r < n) {
        while (l > 2 && a[l - 1] >= mn) {
          --l;
        }
        while (r < n - 1 && a[r + 1] >= mn) {
          ++r;
        }
        if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          if (a[l - 1] > a[r + 1]) {
            mn = a[--l];
          } else {
            mn = a[++r];
          }
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - 1 << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (r < v.back()) {
        mn = min(mn, a[r++]);
      }
      while (l > 1 && r < n) {
        while (l > 1 && a[l - 1] >= mn) {
          --l;
        }
        while (r < n && a[r + 1] >= mn) {
          ++r;
        }
        if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          mn = max(a[l - 1], a[r + 1]);
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - 1 << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (r < v.back()) {
        mn = min(mn, a[r++]);
      }
      while (l > 1 && r < n) {
        while (l > 1 && a[l - 1] >= mn) {
          --l;
        }
        while (r < n && a[r + 1] >= mn) {
          ++r;
        }
        if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          if (a[l - 1] > a[r + 1]) {
            mn = a[--l];
          } else {
            mn = a[++r];
          }
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <set>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10, INF = 1e18;

int a[N], suf[N], seg[N << 2];

void build(int i, int j, int n) {
  if (i == j) {
    seg[n] = a[i];
    return;
  }
  int m = (i + j) >> 1;
  build(i, m, n << 1);
  build(m + 1, j, n << 1 | 1);
  seg[n] = min(seg[n << 1], seg[n << 1 | 1]);
}

int query(int i, int j, int l, int r, int n) {
  if (i > r || j < l) {
      return INF;
  }
  if (i >= l && j <= r) {
    return seg[n];
  }
  int m = (i + j) >> 1;
  return min(query(i, m, l, r, n << 1), query(m + 1, j, l, r, n << 1 | 1));
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    suf[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; --i) {
      suf[i] = max(suf[i + 1], a[i]);
    }
    build(0, n - 1, 1);
    int mx = 0;
    bool ok = 0;
    for (int i = 0; i + 2 < n; ++i) {
      mx = max(mx, a[i]);
      int l = i + 1, r = n - 2;
      while (l + 3 < r) {
        int m = (l + r) >> 1;
        int y = suf[m + 1];
        int x = query(0, n - 1, i + 1, m, 1);
        if (x < mx) {
          r = m - 1;
        } else if (x > mx) {
          l = m + 1;
        } else if (y < mx) {
          r = m - 1;
        } else if (y > mx) {
          l = m + 1;
        } else {
          l = m;
          break;
        }
      }
      while (l < n - 1 && l <= r) {
        int y = suf[l + 1];
        int x = query(0, n - 1, i + 1, l, 1);
        if (x == y && x == mx) {
          ok = 1;
          cout << "YES\n" << i + 1 << ' ' << l - i << ' ' << n - l - 1 << '\n';
          break;
        }
        ++l;
      }
      if (ok) {
        break;
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - 1 << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (l > 1 && r < n) {
        while (1) {
          int p = l, q = r;
          while (l > 2 && pre[l - 1] > mn) {
            mn = min(mn, a[--l]);
          }
          while (r < n - 1 && suf[r + 1] > mn) {
            mn = min(mn, a[++r]);
          }
          if (p - q == l - r) {
            break;
          }
        }
        if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          if (r == n - 1) {
            mn = a[--l];
          } else if (l == 2) {
            mn = a[++r];
          } else {
            if (pre[l - 1] > pre[r + 1]) {
              mn = a[--l];
            } else {
              mn = a[++r];
            }
          }
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - 1 << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (r < v.back()) {
        mn = min(mn, a[r++]);
      }
      while (l > 1 && r < n) {
        while (l > 1 && a[l - 1] >= mn) {
          --l;
        }
        while (r < n && a[r + 1] >= mn) {
          ++r;
        }
        if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          if (pre[l - 1] > suf[r + 1]) {
            mn = pre[--l];
          } else {
            mn = suf[++r];
          }
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - 1 << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (r < v.back()) {
        mn = min(mn, a[r++]);
      }
      while (l > 1 && r < n) {
        while (l > 1 && a[l - 1] >= mn) {
          --l;
        }
        while (r < n && a[r + 1] >= mn) {
          ++r;
        }
        if (l > 1 && r < n) {
          if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
            ok = 1;
            cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
            break;
          } else {
            mn = max(a[l - 1], a[r + 1]);
          }
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - v[0] << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (r < v.back()) {
        mn = min(mn, a[r++]);
      }
      while (l > 1 && r < n) {
        while (l > 1 && a[l - 1] >= mn) {
          --l;
        }
        while (r < n && a[r + 1] >= mn) {
          ++r;
        }
        if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          mn = max(mn, max(pre[l - 1], suf[r + 1]));
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - 1 << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (l > 1 && r < n) {
        while (1) {
          int p = l, q = r;
          while (l > 2 && pre[l - 1] > mn) {
            mn = min(mn, a[--l]);
          }
          while (r < n - 1 && suf[r + 1] > mn) {
            mn = min(mn, a[++r]);
          }
          if (p - q == l - r) {
            break;
          }
        }
        if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          if (r == n - 1) {
            mn = a[++r];
          } else if (l == 2) {
            mn = a[--l];
          } else {
            if (a[l - 1] > a[r + 1]) {
              mn = a[--l];
            } else {
              mn = a[++r];
            }
          }
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - 1 << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (r < v.back()) {
        mn = min(mn, a[r++]);
      }
      while (l > 1 && r < n) {
        while (l > 1 && a[l - 1] >= mn) {
          --l;
        }
        while (r < n && a[r + 1] >= mn) {
          ++r;
        }
        if (l > 1 && r < n && pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          mn = max(a[l - 1], a[r + 1]);
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[0] << ' ' << v[1] - v[0] << ' ' << n - v[1] << '\n';
    } else {
      suf[n] = a[n]
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (r < v.back()) {
        mn = min(mn, a[r++]);
      }
      while (l > 1 && r < n) {
        while (l > 1 && a[l - 1] >= mn) {
          --l;
        }
        while (r < n && a[r + 1] >= mn) {
          ++r;
        }
        if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          mn = max(mn, max(pre[l - 1], suf[r + 1]));
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


#include <vector>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N], pre[N], suf[N];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = max(pre[i - 1], a[i]);
    }
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
      if (pre[n] == a[i]) {
        v.push_back(i);
      }
    }
    bool ok = 0;
    if (v.size() > 2) {
      ok = 1;
      cout << "YES\n" << v[1] - 1 << " 1 " << n - v[1] << '\n';
    } else {
      suf[n] = a[n];
      for (int i = n; --i;) {
        suf[i] = max(suf[i + 1], a[i]);
      }
      int l = v[0], r = v[0], mn = pre[n];
      while (r < v.back()) {
        mn = min(mn, a[r++]);
      }
      while (l > 1 && r < n) {
        while (l > 1 && a[l - 1] >= mn) {
          --l;
        }
        while (r < n && a[r + 1] >= mn) {
          ++r;
        }
        if (pre[l - 1] == suf[r + 1] && pre[l - 1] == mn) {
          ok = 1;
          cout << "YES\n" << l - 1 << ' ' << r - l + 1 << ' ' << n - r << '\n';
          break;
        } else {
          mn = max(mn, max(pre[l - 1], suf[r + 1]));
        }
      }
    }
    if (!ok) {
      cout << "NO\n";
    }
  }
  return 0;
}


# include<bits/stdc++.h>
using namespace std;
# define l long long
# define db double
# define rep(i,a,b) for(l i=a;i<b;i++)
# define vi vector<l>
# define pb push_back
# define mp make_pair
# define ss second
# define ff first
# define pii pair<l,l>
# define trvi(v,it) for(vi::iterator it=v.begin();it!=v.end();++it)
# define read(a) freopen(a,"r",stdin)
# define write(a) freopen(a,"w",stdout)
# define io ios::sync_with_stdio(false)
const l MOD=1e9+7;
const l N=2e5+5;
const l INF=1e12;
#define mini first
#define maxi second

l n=0;
vector<pii> segTree(2*N);

pii merge(pii a, pii b) {
	pii ans = mp(0,0);
	ans.mini=min(a.mini,b.mini);
	ans.maxi=max(a.maxi,b.maxi);
	return ans;

}

void clear() {
	rep(i,1,2*n) {
		segTree[i]=mp(0,0);
	}
}

void build() {
	for(l i=n-1;i>0;i--) {
		segTree[i]=merge(segTree[2*i],segTree[2*i+1]);
	}
}

pii query(l ll, l r) {
	ll+=n;
	r+=n;
	pii res(INF,-1*INF); // Initialize to default
	while(ll<r) {
		if(ll%2==1) {
			res=merge(segTree[ll],res);
			ll++;
		}
		if(r%2==1) {
			r--;
			res=merge(segTree[r],res);
		}
		ll/=2;
		r/=2;
	}
	return res;
}

pii rangeMax(l rgt, l val) {
	l left=0;
	l right=rgt;
	pii ans=mp(0,0);
	while(left<right) {
		l mid=(left+right)/2;
		l midVal=query(0,mid+1).maxi;
		// cout<<"mid="<<mid<<" midVal="<<midVal<<"\n";
		if(midVal<val) {
			left=mid+1;
		} else {
			right=mid;
		}
	}
	// cout<<"midVal "<<left<<"\n";
	ans.ff=left;
	left=0;
	right=rgt;
	while(left<right) {
		l mid=(left+right+1)/2;
		l midVal=query(0,mid+1).maxi;
		// cout<<"mid="<<mid<<" midVal="<<midVal<<"\n";
		if(midVal<=val) {
			left=mid;
		} else {
			right=mid-1;
		}
	}
	// cout<<"midVal "<<left<<"\n";
	ans.ss=left;
	if(query(0,left+1).maxi!=val) {
		ans=mp(-1,-1);
	}
	return ans;

}

pii rangeMin(l rgt, l val) {
	l left=0;
	l right=rgt;
	pii ans=mp(0,0);
	while(left<right) {
		l mid=(left+right)/2;
		l midVal=query(mid,right+1).mini;
		// cout<<"mid="<<mid<<" midVal="<<midVal<<"\n";
		if(midVal<val) {
			left=mid+1;
		} else {
			right=mid;
		}
	}
	// cout<<"midVal "<<left<<"\n";
	ans.ff=left;
	left=0;
	right=rgt;
	while(left<right) {
		l mid=(left+right+1)/2;
		l midVal=query(mid,right+1).mini;
		// cout<<"mid="<<mid<<" midVal="<<midVal<<"\n";
		if(midVal<=val) {
			left=mid;
		} else {
			right=mid-1;
		}
	}
	// cout<<"midVal "<<left<<"\n";
	ans.ss=left;
	if(query(left,right+1).mini!=val) {
		ans=mp(-1,-1);
	}
	return ans;
}

void solve() {
	clear();
	cin>>n;
	rep(i,0,n) {
		l val;
		cin>>val;
		segTree[n+i]=mp(val,val);

	}
	build();
	l start=0, end=n;
	l i=1;
	rep(j,2,n) {
		l rightVal=query(j,end).maxi;
		pii range1=rangeMax(j-1,rightVal);
		pii range2=rangeMin(j-1,rightVal);
		// cout<<"j="<<j<<" minRange="<<range2.ff<<" "<<range2.ss<<" maxRange="<<range1.ff<<" "<<range1.ss<<" val"<<rightVal<<"\n";
		if(range1.ff==-1 || range2.ff==-1) {
			continue;
		}
		range1.ff++;
		range1.ss++;
		if(range1.ff<=range2.ff && (range2.ff<=range1.ss)) {
			cout<<"YES\n";
			cout<<range2.ff<<" "<<j-range2.ff<<" "<<n-j<<"\n";
			return;
		} else if(range2.ff<=range1.ff && range1.ff<=range2.ss) {
			cout<<"YES\n";
			cout<<range1.ff<<" "<<j-range1.ff<<" "<<n-j<<"\n";
			return;
		} else {
			continue;
		}

	}
	cout<<"NO\n";
	// cout<<query(1,4).ff<<" "<<query(1,4).ss<<"\n";

	return;
}

int main(){
	io;
	int t;
	cin >> t;
	rep(i,0,t) {
		solve();
	}

	return 0;
}


# include<bits/stdc++.h>
using namespace std;
# define l long long
# define db double
# define rep(i,a,b) for(l i=a;i<b;i++)
# define vi vector<l>
# define pb push_back
# define mp make_pair
# define ss second
# define ff first
# define pii pair<l,l>
# define trvi(v,it) for(vi::iterator it=v.begin();it!=v.end();++it)
# define read(a) freopen(a,"r",stdin)
# define write(a) freopen(a,"w",stdout)
# define io ios::sync_with_stdio(false)
const l MOD=1e9+7;
const l N=2e5+5;
const l INF=1e12;
#define mini first
#define maxi second

l n=0;
vector<pii> segTree(2*N);

pii merge(pii a, pii b) {
	pii ans = mp(0,0);
	ans.mini=min(a.mini,b.mini);
	ans.maxi=max(a.maxi,b.maxi);
	return ans;

}

void clear() {
	rep(i,1,2*n) {
		segTree[i]=mp(0,0);
	}
}

void build() {
	for(l i=n-1;i>0;i--) {
		segTree[i]=merge(segTree[2*i],segTree[2*i+1]);
	}
}

pii query(l ll, l r) {
	ll+=n;
	r+=n;
	pii res(INF,-1*INF); // Initialize to default
	while(ll<r) {
		if(ll%2==1) {
			res=merge(segTree[ll],res);
			ll++;
		}
		if(r%2==1) {
			r--;
			res=merge(segTree[r],res);
		}
		ll/=2;
		r/=2;
	}
	return res;
}

void solve() {
	clear();
	cin>>n;
	rep(i,0,n) {
		l val;
		cin>>val;
		segTree[n+i]=mp(val,val);

	}
	build();
	l start=0, end=n;
	l i=1,j=n-1;
	l cnt=0;
	while(i<j) {
		cnt++;
		l max0=query(start,i).maxi;
		l min1=query(i,j).mini;
		l max2=query(j,end).maxi;
		// cout<<i<<" "<<j<<" "<<max0<<" "<<min1<<" "<<max2<<"\n";
		if(max0==min1 && max0==max2) {
			cout<<"YES\n";
			cout<<i<<" "<<j-i<<" "<<n-j<<"\n";
			return;
		}

		if(max0>max2) {
			j--;
		} else if(max0<max2) {
			i++;
		} else if(segTree[n+i]<segTree[n+j-1]) {
			i++;
		} else if(segTree[n+i]>segTree[n+j-1]) {
			j--;
		} else {
			i++;
			j--;
		}

	}
	cout<<"NO\n";
	// cout<<query(1,4).ff<<" "<<query(1,4).ss<<"\n";

	return;
}

int main(){
	io;
	int t;
	cin >> t;
	rep(i,0,t) {
		solve();
	}

	return 0;
}


# include<bits/stdc++.h>
using namespace std;
# define l long long
# define db double
# define rep(i,a,b) for(l i=a;i<b;i++)
# define vi vector<l>
# define pb push_back
# define mp make_pair
# define ss second
# define ff first
# define pii pair<l,l>
# define trvi(v,it) for(vi::iterator it=v.begin();it!=v.end();++it)
# define read(a) freopen(a,"r",stdin)
# define write(a) freopen(a,"w",stdout)
# define io ios::sync_with_stdio(false)
const l MOD=1e9+7;
const l N=2e5+5;
const l INF=1e12;
#define mini first
#define maxi second

l n=0;
vector<pii> segTree(2*N);

pii merge(pii a, pii b) {
	pii ans = mp(0,0);
	ans.mini=min(a.mini,b.mini);
	ans.maxi=max(a.maxi,b.maxi);
	return ans;

}

void clear() {
	rep(i,1,2*n) {
		segTree[i]=mp(0,0);
	}
}

void build() {
	for(l i=n-1;i>0;i--) {
		segTree[i]=merge(segTree[2*i],segTree[2*i+1]);
	}
}

pii query(l ll, l r) {
	ll+=n;
	r+=n;
	pii res(INF,-1*INF); // Initialize to default
	while(ll<r) {
		if(ll%2==1) {
			res=merge(segTree[ll],res);
			ll++;
		}
		if(r%2==1) {
			r--;
			res=merge(segTree[r],res);
		}
		ll/=2;
		r/=2;
	}
	return res;
}

void solve() {
	clear();
	cin>>n;
	rep(i,0,n) {
		l val;
		cin>>val;
		segTree[n+i]=mp(val,val);

	}
	build();
	l start=0, end=n;
	l i=1,j=n-1;
	// l cnt=0;
	while(i<j) {
		l max0=query(start,i).maxi;
		l min1=query(i,j).mini;
		l max2=query(j,end).maxi;
		// cout<<i<<" "<<j<<" "<<max0<<" "<<min1<<" "<<max2<<"\n";
		if(max0==min1 && max0==max2) {
			cout<<"YES\n";
			cout<<i<<" "<<j-i<<" "<<n-j<<"\n";
			return;
		}

		if(max0>max2) {
			j--;
		} else if(max0<max2) {
			i++;
		} else if(segTree[n+i].ff<segTree[n+j-1].ff) {
			i++;
		} else if(segTree[n+i].ff>segTree[n+j-1].ff) {
			j--;
		} else {
			i++;
		}

	}
	cout<<"NO\n";
	// cout<<query(1,4).ff<<" "<<query(1,4).ss<<"\n";

	return;
}

int main(){
	io;
	int t;
	cin >> t;
	rep(i,0,t) {
		solve();
	}

	return 0;
}


# include<bits/stdc++.h>
using namespace std;
# define l long long
# define db double
# define rep(i,a,b) for(l i=a;i<b;i++)
# define vi vector<l>
# define pb push_back
# define mp make_pair
# define ss second
# define ff first
# define pii pair<l,l>
# define trvi(v,it) for(vi::iterator it=v.begin();it!=v.end();++it)
# define read(a) freopen(a,"r",stdin)
# define write(a) freopen(a,"w",stdout)
# define io ios::sync_with_stdio(false)
const l MOD=1e9+7;
const l N=2e5+5;
const l INF=1e12;
#define mini first
#define maxi second

l n=0;
vector<pii> segTree(2*N);
vi prefixMax(N+1,0), suffixMax(N+1,0);

pii merge(pii a, pii b) {
	pii ans = mp(0,0);
	ans.mini=min(a.mini,b.mini);
	ans.maxi=max(a.maxi,b.maxi);
	return ans;

}

void clear() {
	rep(i,1,2*n) {
		segTree[i]=mp(0,0);
	}
	rep(i,0,n+1) {
		prefixMax[i]=0;
		suffixMax[i]=0;
	}
}

void build() {
	for(l i=n-1;i>0;i--) {
		segTree[i]=merge(segTree[2*i],segTree[2*i+1]);
	}
}

pii query(l ll, l r) {
	ll+=n;
	r+=n;
	pii res(INF,-1*INF); // Initialize to default
	while(ll<r) {
		if(ll%2==1) {
			res=merge(segTree[ll],res);
			ll++;
		}
		if(r%2==1) {
			r--;
			res=merge(segTree[r],res);
		}
		ll/=2;
		r/=2;
	}
	return res;
}

pii rangeMax(l rgt, l val) {
	l left=0;
	l right=rgt;
	pii ans=mp(0,0);
	while(left<right) {
		l mid=(left+right)/2;
		l midVal=prefixMax[mid+1];
		// l midVal=query(0,mid+1).maxi;
		// cout<<"mid="<<mid<<" midVal="<<midVal<<"\n";
		if(midVal<val) {
			left=mid+1;
		} else {
			right=mid;
		}
	}
	// cout<<"midVal "<<left<<"\n";
	ans.ff=left;
	left=0;
	right=rgt;
	while(left<right) {
		l mid=(left+right+1)/2;
		l midVal=prefixMax[mid+1];
		// l midVal=query(0,mid+1).maxi;
		// cout<<"mid="<<mid<<" midVal="<<midVal<<"\n";
		if(midVal<=val) {
			left=mid;
		} else {
			right=mid-1;
		}
	}
	// cout<<"midVal "<<left<<"\n";
	ans.ss=left;
	if(query(0,left+1).maxi!=val) {
		ans=mp(-1,-1);
	}
	return ans;

}

pii rangeMin(l rgt, l val) {
	l left=0;
	l right=rgt;
	pii ans=mp(0,0);
	while(left<right) {
		l mid=(left+right)/2;
		l midVal=query(mid,right+1).mini;
		// cout<<"mid="<<mid<<" midVal="<<midVal<<"\n";
		if(midVal<val) {
			left=mid+1;
		} else {
			right=mid;
		}
	}
	// cout<<"midVal "<<left<<"\n";
	ans.ff=left;
	left=0;
	right=rgt;
	while(left<right) {
		l mid=(left+right+1)/2;
		l midVal=query(mid,right+1).mini;
		// cout<<"mid="<<mid<<" midVal="<<midVal<<"\n";
		if(midVal<=val) {
			left=mid;
		} else {
			right=mid-1;
		}
	}
	// cout<<"midVal "<<left<<"\n";
	ans.ss=left;
	if(query(left,right+1).mini!=val) {
		ans=mp(-1,-1);
	}
	return ans;
}

void solve() {
	clear();
	cin>>n;
	rep(i,0,n) {
		l val;
		cin>>val;
		segTree[n+i]=mp(val,val);
		prefixMax[i+1]=max(val,prefixMax[i]);
	}
	for(l i=2*n-1;i>=n;i--) {
		suffixMax[i-n]=max(segTree[i].ff,suffixMax[i-n+1]);
	}
	build();
	l start=0, end=n;
	l i=1;
	rep(j,2,n) {
		l rightVal=suffixMax[j];
		// l rightVal=query(j,end).maxi;
		pii range1=rangeMax(j-1,rightVal);
		pii range2=rangeMin(j-1,rightVal);
		// cout<<"j="<<j<<" minRange="<<range2.ff<<" "<<range2.ss<<" maxRange="<<range1.ff<<" "<<range1.ss<<" val"<<rightVal<<"\n";
		if(range1.ff==-1 || range2.ff==-1) {
			continue;
		}
		range1.ff++;
		range1.ss++;
		if(range1.ff<=range2.ff && (range2.ff<=range1.ss)) {
			cout<<"YES\n";
			cout<<range2.ff<<" "<<j-range2.ff<<" "<<n-j<<"\n";
			return;
		} else if(range2.ff<=range1.ff && range1.ff<=range2.ss) {
			cout<<"YES\n";
			cout<<range1.ff<<" "<<j-range1.ff<<" "<<n-j<<"\n";
			return;
		} else {
			continue;
		}

	}
	cout<<"NO\n";
	// cout<<query(1,4).ff<<" "<<query(1,4).ss<<"\n";

	return;
}

int main(){
	io;
	int t;
	cin >> t;
	rep(i,0,t) {
		solve();
	}

	return 0;
}


# include<bits/stdc++.h>
using namespace std;
# define l long long
# define db double
# define rep(i,a,b) for(l i=a;i<b;i++)
# define vi vector<l>
# define pb push_back
# define mp make_pair
# define ss second
# define ff first
# define pii pair<l,l>
# define trvi(v,it) for(vi::iterator it=v.begin();it!=v.end();++it)
# define read(a) freopen(a,"r",stdin)
# define write(a) freopen(a,"w",stdout)
# define io ios::sync_with_stdio(false)
const l MOD=1e9+7;
const l N=1e5+5;
const l INF=1e12;
#define mini first
#define maxi second

l n;
vector<pii> segTree(2*N);

pii merge(pii a, pii b) {
	pii ans = mp(0,0);
	ans.mini=min(a.mini,b.mini);
	ans.maxi=max(a.maxi,b.maxi);
	return ans;

}

void build() {
	for(l i=n-1;i>0;i--) {
		segTree[i]=merge(segTree[2*i],segTree[2*i+1]);
	}
}

pii query(l ll, l r) {
	ll+=n;
	r+=n;
	pii res(INT_MAX,INT_MIN); // Initialize to default
	while(ll<r) {
		if(ll%2==1) {
			res=merge(segTree[ll],res);
			ll++;
		}
		if(r%2==1) {
			r--;
			res=merge(segTree[r],res);
		}
		ll/=2;
		r/=2;
	}
	return res;
}

void solve() {
	cin>>n;
	rep(i,0,n) {
		l val;
		cin>>val;
		segTree[n+i]=mp(val,val);

	}
	build();
	l start=0, end=n;
	l i=1,j=n-1;
	l cnt=0;
	while(i<j) {
		cnt++;
		l max0=query(start,i).maxi;
		l min1=query(i,j).mini;
		l max2=query(j,end).maxi;
		// cout<<i<<" "<<j<<" "<<max0<<" "<<min1<<" "<<max2<<"\n";
		if(max0==min1 && max0==max2) {
			cout<<"YES\n";
			cout<<i<<" "<<j-i<<" "<<n-j<<"\n";
			return;
		}

		if(max0>max2) {
			j--;
		} else if(max0<max2) {
			i++;
		} else if(segTree[n+i]<segTree[n+j-1]) {
			i++;
		} else {
			j--;
		}

	}
	cout<<"NO\n";
	// cout<<query(1,4).ff<<" "<<query(1,4).ss<<"\n";

	return;
}

int main(){
	io;
	int t;
	cin >> t;
	rep(i,0,t) {
		solve();
	}

	return 0;
}


# include<bits/stdc++.h>
using namespace std;
# define l long long
# define db double
# define rep(i,a,b) for(l i=a;i<b;i++)
# define vi vector<l>
# define pb push_back
# define mp make_pair
# define ss second
# define ff first
# define pii pair<l,l>
# define trvi(v,it) for(vi::iterator it=v.begin();it!=v.end();++it)
# define read(a) freopen(a,"r",stdin)
# define write(a) freopen(a,"w",stdout)
# define io ios::sync_with_stdio(false)
const l MOD=1e9+7;
const l N=2e5+5;
const l INF=1e12;
#define mini first
#define maxi second

l n=0;
vector<pii> segTree(2*N);

pii merge(pii a, pii b) {
	pii ans = mp(0,0);
	ans.mini=min(a.mini,b.mini);
	ans.maxi=max(a.maxi,b.maxi);
	return ans;

}

void clear() {
	rep(i,1,2*n) {
		segTree[i]=mp(0,0);
	}
}

void build() {
	for(l i=n-1;i>0;i--) {
		segTree[i]=merge(segTree[2*i],segTree[2*i+1]);
	}
}

pii query(l ll, l r) {
	ll+=n;
	r+=n;
	pii res(INF,-1*INF); // Initialize to default
	while(ll<r) {
		if(ll%2==1) {
			res=merge(segTree[ll],res);
			ll++;
		}
		if(r%2==1) {
			r--;
			res=merge(segTree[r],res);
		}
		ll/=2;
		r/=2;
	}
	return res;
}

void solve() {
	clear();
	cin>>n;
	rep(i,0,n) {
		l val;
		cin>>val;
		segTree[n+i]=mp(val,val);

	}
	build();
	l start=0, end=n;
	l i=1,j=n-1;
	l cnt=0;
	while(i<j) {
		cnt++;
		l max0=query(start,i).maxi;
		l min1=query(i,j).mini;
		l max2=query(j,end).maxi;
		// cout<<i<<" "<<j<<" "<<max0<<" "<<min1<<" "<<max2<<"\n";
		if(max0==min1 && max0==max2) {
			cout<<"YES\n";
			cout<<i<<" "<<j-i<<" "<<n-j<<"\n";
			return;
		}

		if(max0>max2) {
			j--;
		} else if(max0<max2) {
			i++;
		} else if(segTree[n+i]<segTree[n+j-1]) {
			i++;
		} else if(segTree[n+i]>segTree[n+j-1]) {
			j--;
		} else {
			i++;
		}

	}
	cout<<"NO\n";
	// cout<<query(1,4).ff<<" "<<query(1,4).ss<<"\n";

	return;
}

int main(){
	io;
	int t;
	cin >> t;
	rep(i,0,t) {
		solve();
	}

	return 0;
}


# include<bits/stdc++.h>
using namespace std;
# define l long long
# define db double
# define rep(i,a,b) for(l i=a;i<b;i++)
# define vi vector<l>
# define pb push_back
# define mp make_pair
# define ss second
# define ff first
# define pii pair<l,l>
# define trvi(v,it) for(vi::iterator it=v.begin();it!=v.end();++it)
# define read(a) freopen(a,"r",stdin)
# define write(a) freopen(a,"w",stdout)
# define io ios::sync_with_stdio(false)
const l MOD=1e9+7;
const l N=2e5+5;
const l INF=1e12;
#define mini first
#define maxi second

l t;
l cnt=1;

l n=0;
vector<pii> segTree(2*N);

pii merge(pii a, pii b) {
	pii ans = mp(0,0);
	ans.mini=min(a.mini,b.mini);
	ans.maxi=max(a.maxi,b.maxi);
	return ans;

}

void clear() {
	rep(i,1,2*n) {
		segTree[i]=mp(0,0);
	}
}

void build() {
	for(l i=n-1;i>0;i--) {
		segTree[i]=merge(segTree[2*i],segTree[2*i+1]);
	}
}

pii query(l ll, l r) {
	ll+=n;
	r+=n;
	pii res(INF,-1*INF); // Initialize to default
	while(ll<r) {
		if(ll%2==1) {
			res=merge(segTree[ll],res);
			ll++;
		}
		if(r%2==1) {
			r--;
			res=merge(segTree[r],res);
		}
		ll/=2;
		r/=2;
	}
	return res;
}

void solve() {
	clear();
	cin>>n;
	rep(i,0,n) {
		l val;
		cin>>val;
		segTree[n+i]=mp(val,val);

	}
	build();
	l start=0, end=n;
	l i=1,j=n-1;
	// l cnt=0;
	while(i<j) {
		l max0=query(start,i).maxi;
		l min1=query(i,j).mini;
		l max2=query(j,end).maxi;
		// cout<<i<<" "<<j<<" "<<max0<<" "<<min1<<" "<<max2<<"\n";
		if(max0==min1 && max0==max2) {
			if(t<720) {
				cout<<"YES\n";
				cout<<i<<" "<<j-i<<" "<<n-j<<"\n";
			}
			//
			return;
		}

		if(max0>max2) {
			j--;
		} else if(max0<max2) {
			i++;
		} else if(segTree[n+i].ff<segTree[n+j-1].ff) {
			i++;
		} else if(segTree[n+i].ff>segTree[n+j-1].ff) {
			j--;
		} else {
			i++;
		}

	}
	if(cnt==721) {
		cout<<n<<"\n";
		rep(i,0,n) {
			cout<<segTree[n+i].mini<<" ";
		}
		cout<<"\n";
	}
	if(t<720) {
		cout<<"NO\n";
	}

	// cout<<"NO\n";
	// cout<<query(1,4).ff<<" "<<query(1,4).ss<<"\n";

	return;
}

int main(){
	io;
	cin >> t;
	rep(i,0,t) {
		solve();
		cnt++;
	}

	return 0;
}


# include<bits/stdc++.h>
using namespace std;
# define l long long
# define db double
# define rep(i,a,b) for(l i=a;i<b;i++)
# define vi vector<l>
# define pb push_back
# define mp make_pair
# define ss second
# define ff first
# define pii pair<l,l>
# define trvi(v,it) for(vi::iterator it=v.begin();it!=v.end();++it)
# define read(a) freopen(a,"r",stdin)
# define write(a) freopen(a,"w",stdout)
# define io ios::sync_with_stdio(false)
const l MOD=1e9+7;
const l N=1e5+5;
const l INF=1e12;
#define mini first
#define maxi second

l n;
vector<pii> segTree(2*N);

pii merge(pii a, pii b) {
	pii ans = mp(0,0);
	ans.mini=min(a.mini,b.mini);
	ans.maxi=max(a.maxi,b.maxi);
	return ans;

}

void build() {
	for(l i=n-1;i>0;i--) {
		segTree[i]=merge(segTree[2*i],segTree[2*i+1]);
	}
}

pii query(l ll, l r) {
	ll+=n;
	r+=n;
	pii res(INT_MAX,INT_MIN); // Initialize to default
	while(ll<r) {
		if(ll%2==1) {
			res=merge(segTree[ll],res);
			ll++;
		}
		if(r%2==1) {
			r--;
			res=merge(segTree[r],res);
		}
		ll/=2;
		r/=2;
	}
	return res;
}

void solve() {
	cin>>n;
	rep(i,0,n) {
		l val;
		cin>>val;
		segTree[n+i]=mp(val,val);

	}
	build();
	l start=0, end=n;
	l i=1,j=n-1;
	l cnt=0;
	while(i<j) {
		cnt++;
		l max0=query(start,i).maxi;
		l min1=query(i,j).mini;
		l max2=query(j,end).maxi;
		// cout<<i<<" "<<j<<" "<<max0<<" "<<min1<<" "<<max2<<"\n";
		if(max0==min1 && max0==max2) {
			cout<<"YES\n";
			cout<<i<<" "<<j-i<<" "<<n-j<<"\n";
			return;
		}

		if(max0>max2) {
			j--;
		} else if(max0<max2) {
			i++;
		} else if(segTree[n+i]<segTree[n+j-1]) {
			i++;
		} else if(segTree[n+i]>segTree[n+j-1]) {
			j--;
		} else {
			i++;
			j--;
		}

	}
	cout<<"NO\n";
	// cout<<query(1,4).ff<<" "<<query(1,4).ss<<"\n";

	return;
}

int main(){
	io;
	int t;
	cin >> t;
	rep(i,0,t) {
		solve();
	}

	return 0;
}


#include <iostream>
using namespace std;

void main()
{
	long long s=0,m=0;
	char ch=char(48);
	while(ch!=char(10))
	{
		cin>>ch;
		if(ch=='-') s--; else s++;
		m=max(m,abs(s));
		ch=cin.peek();
	}
	cout<<m;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int cntw,cntn,ans;
    string str;
    while (cin>>str)
    {
        ans=cntw=cntn=0;
        for (int ix=0;ix!=str.size();ix++)
        {
            if (str[ix]=='+')
            {
                if (cntw==0)
                {
                    ans++;
                    cntn++;
                }
                else
                {
                    cntw--;
                    cntn++;
                }
            }
            else if (str[ix]=='-')
            {
                if (cntn==0)
                {
                    ans++;
                    cntw++;
                }
                else
                {
                    cntn--;
                    cntw++;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int ans;
    string str;
    while (cin>>str)
    {
        ans=1;
        for (int ix=1;ix!=str.size();ix++)
            if (str[ix]==str[ix-1])
                ans++;
        cout<<ans<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
    string str;
    int plus,min;
    while (cin>>str)
    {
        plus=min=0;
        for (int ix=0;ix!=str.size();ix++)
        {
            if (str[ix]=='+') plus++;
            else if (str[ix]=='-') min++;
        }
        cout<<abs(plus-min)<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str;
    int plus,min,cntp,cntm,ans;
    while (cin>>str)
    {
        ans=1;
        plus=min=cntp=cntm=0;
        for (int ix=1;ix!=str.size();ix++)
            if (str[ix]==str[ix-1])
            {
                if (str[ix]=='+')
                {
                    if (cntm!=0)
                        cntm--;
                    else
                    {
                        cntp++;
                        ans++;
                    }
                }
                else
                {
                    if (cntp!=0)
                        cntp--;
                    else
                    {
                        cntm++;
                        ans++;
                    }
                }
            }
            cout<<ans<<endl;

    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>       //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>      //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

#define MR 310

char s[MR];

int main()
{
    scanf("%s", s);
    int n = strlen(s);
    int res = 0;
    for(int i = 0; i < n;)
    {
        int j = i+1;
        while(j < n && s[i] == s[j])j++;
        res = max(res,j-i);
        i = j;
    }
    printf("%d\n", res);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>       //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>      //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

#define MR 310

char s[MR];

int main()
{
    scanf("%s", s);
    int n = strlen(s);
    int maxv = 0, minv = MR, v = 0;
    REP(i,n)
    {
        if(s[i] == '+') v++;
        else v--;
        maxv = max(maxv,v);
        minv = min(minv,v);
    }
    printf("%d\n", max(maxv,abs(minv)));
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>       //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>      //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

#define MR 310

char s[MR];
int t[MR];

int main()
{
    memset(t,-1,sizeof(t));
    scanf("%s", s);
    int n = strlen(s);
    REP(i,n)
        if(s[i] == '+')
        {
            bool ok = 0;
            REP(j,n)
                if(t[j] == 1)
                {
                    ok = 1;
                    t[j] = 0;
                    break;
                }
            if(!ok)
                REP(j,n)
                    if(t[j] == -1)
                    {
                        t[j] = 0;
                        break;
                    }
        }
        else
        {
            bool ok = 0;
            REP(j,n)
                if(t[j] == 0)
                {
                    ok = 1;
                    t[j] = 1;
                    break;
                }
            if(!ok)
                REP(j,n)
                    if(t[j] == -1)
                    {
                        t[j] = 1;
                        break;
                    }
        }
    int res = 0;
    REP(i,n)
        if(t[i] != -1) res++;
    printf("%d\n", res);
    return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <stack>

using namespace std;

#define forn(i, n) for(int i=0;i<n;++i)
#define forv(i, v) for(int i=0;i<v.size();++i)
#define pb push_back
#define mp make_pair
#define lng long long

int f(string s) {
    int res=0;
    int bal=0;
    forv(i,s){
        if (s[i]=='+')++bal;else --bal;
        res=max(res, abs(bal));
    }
    return res;
}

int ff(string s) {
    int res=0;
    forv(i, s)
        for(int j=1;j<=s.length();++j)
            res=max(res, f(s.substr(i, j)));
    return res;
}
int main() {
#ifdef __ASD__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int i =0;
    int res=0;
    int n = s.length();
    while (i<n) {
        int j = i;
        while (j<n && s[j]==s[i])++j;
        res=max(res,j -i);
        i=j;
    }
    s = "123";
    s = s.substr(1, 1);
    cout<<max(res, ff(s));
    return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <stack>

using namespace std;

#define forn(i, n) for(int i=0;i<n;++i)
#define forv(i, v) for(int i=0;i<v.size();++i)
#define pb push_back
#define mp make_pair
#define lng long long

int main() {
#ifdef __ASD__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int t = 0;
    int res = 0;
    forv(i, s) {
        if (s[i]=='-')++t;else --t;
        res = max(res, abs(t));
    }
    cout << res;

    return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <stack>

using namespace std;

#define forn(i, n) for(int i=0;i<n;++i)
#define forv(i, v) for(int i=0;i<v.size();++i)
#define pb push_back
#define mp make_pair
#define lng long long

int f(string s) {
    int res=0;
    int bal=0;
    forv(i,s){
        if (s[i]=='+')++bal;else --bal;
        res=max(res, abs(bal));
    }
    return res;
}

int ff(string s) {
    int res=0;
    forv(i, s)
        for(int j=1;j<=s.length();++j)
            res=max(res, f(s.substr(i, j)));
    return res;
}
int main() {
#ifdef __ASD__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int i =0;
    int res=0;
    int n = s.length();
    while (i<n) {
        int j = i;
        while (j<n && s[j]==s[i])++j;
        res=max(res,j -i);
        i=j;
    }
    cout<<max(res, ff(s));
    return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <stack>

using namespace std;

#define forn(i, n) for(int i=0;i<n;++i)
#define forv(i, v) for(int i=0;i<v.size();++i)
#define pb push_back
#define mp make_pair
#define lng long long

int f(string s) {
    int res=0;
    int bal=0;
    forv(i,s){
        if (s[i]=='+')++bal;else --bal;
        res=max(res, abs(bal));
    }
    return res;
}

int ff(string s) {
    int res=0;
    forv(i, s)
        for(int j=1;j<=s.length();++j)
            res=max(res, f(s.substr(i, j)));
    return res;
}
int main() {
#ifdef __ASD__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int i =0;
    int res=0;
    int n = s.length();
    while (i<n) {
        int j = i;
        while (j<n && s[j]==s[i])++j;
        res=max(res,j -i);
        i=j;
    }
    cout<<max(ff(s), ff(s));
    return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <stack>

using namespace std;

#define forn(i, n) for(int i=0;i<n;++i)
#define forv(i, v) for(int i=0;i<v.size();++i)
#define pb push_back
#define mp make_pair
#define lng long long

int src[100][100];
int m[100][100];
int res[100];
int tt[100];

int main() {
#ifdef __ASD__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int i =0;
    int res=0;
    int n = s.length();
    while (i<n) {
        int j = i;
        while (j<n && s[j]==s[i])++j;
        res=max(res,j -i);
        i=j;
    }
    cout<<res;
    return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <stack>

using namespace std;

#define forn(i, n) for(int i=0;i<n;++i)
#define forv(i, v) for(int i=0;i<v.size();++i)
#define pb push_back
#define mp make_pair
#define lng long long

int f(string s) {
    int res=0;
    int bal=0;
    forv(i,s){
        if (s[i]=='+')++bal;else --bal;
        res=max(res, abs(bal));
    }
    return res;
}

int main() {
#ifdef __ASD__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int i =0;
    int res=0;
    int n = s.length();
    while (i<n) {
        int j = i;
        while (j<n && s[j]==s[i])++j;
        res=max(res,j -i);
        i=j;
    }
    cout<<max(res, f(s));
    return 0;
}


#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <climits>
#include <ctime>

using namespace std;

const int MOD = 1000000007;
//__int64
__int64 a[500000];

string SS[15];

int main() {
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");

    __int64 n, m, t, y, sum = 0, x = 0, cnt = 1, a = 0, b = 0, A, B;
    string s;
    string res;
    int flg, check;
    char ch1 = '+', ch2 = '-', ch, c;
    cin >> s;
    c = s[0];
    for (int i = 1; i < s.length(); ++i) {
        if (s[i] == c)
            flg = 1;
        else
            flg = 0;
        if (flg == 1)
            ++cnt;
        c = s[i];
    }
    cout << cnt;
    //system("PAUSE");
    return 0;
}


#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <climits>
#include <ctime>

using namespace std;

const int MOD = 1000000007;
//__int64
__int64 a[500000];

string SS[15];

int main() {
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");

    int n, t, m = 0, y, sum = 0, x = 0, cnt = 1, a = 0, b = 0, A, B, plus = 0, minus = 0;
    string s;
    string res;
    cin >> s;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '+') {
            ++plus;
            a = max(minus - 1, m);
            minus = a;
        }
        if (s[i] == '-') {
            ++minus;
            b = max(plus - 1, m);
            plus = b;
        }
    }
    cout << plus + minus;
    //system("PAUSE");
    return 0;
}


#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <climits>
#include <ctime>

using namespace std;

const int MOD = 1000000007;
//__int64
__int64 a[500000];

string SS[15];

int main() {
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");

    int n, t, y, sum = 0, x = 0, cnt = 1, a = 0, b = 0, A, B, plus = 0, minus = 0;
    string s;
    string res;
    int flg, check;
    char ch1 = '+', ch2 = '-', ch, c;
    cin >> s;
    c = s[0];
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '+')
            ++plus;
        else
            ++minus;
    }
    int m = max(plus, minus);
    for (int i = 1; i < s.length(); ++i) {
        if (s[i] == c)
            flg = 1;
        else
            flg = 0;
        if (flg == 1)
            ++cnt;
        c = s[i];
    }
    cout << min(cnt, m);
    //system("PAUSE");
    return 0;
}


#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <climits>
#include <ctime>

using namespace std;

const int MOD = 1000000007;
//__int64
__int64 a[500000];

string SS[15];

int main() {
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");

    int n, t, m = 0, y, sum = 0, x = 0, cnt = 1, a = 0, b = 0, A, B, plus = 0, minus = 0;
    string s;
    string res;
    cin >> s;
    for (int i = 1; i < s.length(); ++i) {
        if (s[i] == s[i - 1]) {
            ++cnt;
            continue;
        }
        m = max(m, cnt);
        cnt = 1;
    }
    m = max(m, cnt);
    cout << m;
    //system("PAUSE");
    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main()
{
    char c;
    int bal = 0;
    int resmin = 0, resmax=0;
    while(cin>>c)
    {
        if(c == '+')
            bal++;
        if(c == '-')
            bal--;
        resmax = max(resmax, bal);
        resmin = min(resmin, bal);
    }
    cout << resmax-resmin << endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main()
{
    char c;
    int bal = 0;
    int res = 0;
    while(cin>>c)
    {
        if(c == '+')
            bal++;
        else
            bal--;
        res = max(res, bal);
        res = max(res, -bal);
    }
    cout << res << endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main()
{
    char c;
    int bal = 0;
    int res = 0;
    while(cin>>c)
    {
        if(c == '+')
            bal++;
        if(c == '-')
            bal--;
        res = max(res, bal);
        res = max(res, -bal);
    }
    cout << res << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
using namespace std;
char str[302];
int i,j,l;
int sum(int p,int q)
{
    int s1=0,s2=0,k;
    for(k=p;k<=q;k++)
    {
        if(str[k]=='+')
            s1++;
        else if(str[k]=='-')
            s2++;
    }
    return abs(s1-s2);
}
int main()
{
    int max;
    while(cin>>str)
    {
        l=strlen(str);
        max=-1;
        for(i=0;i<l;i++)
            for(j=i;j<l;j++)
                if(sum(i,j)>max)
                    max=sum(i,j);
        cout<<max<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
using namespace std;
int right(char ch1,char ch2)
{
    if(ch1=='-'&&ch2=='+')
        return 0;
    if(ch1=='+'&&ch2=='-')
        return 0;
    return 1;
}
int main()
{
    char str[302];
    int i,l;
    while(cin>>str)
    {
        stack<char> s;
        l=strlen(str);
        for(i=0;i<l;i++)
        {
            if(s.empty())
                s.push(str[i]);
            else
            {
                if(right(str[i],s.top())==0)
                    s.pop();
                else
                    s.push(str[i]);
            }
        }
        cout<<s.size()<<endl;
    }
    return 0;
}


#include<iostream>

#include<string>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
using namespace std;
char str[302];
int i,j,l;
int sum(int p,int q)
{
    int s1=0,s2=0,k;
    for(k=p;k<=q;k++)
    {
        if(str[k]=='+')
            s1++;
        else if(str[k]=='-')
            s2++;
    }
    return abs(s1-s2);
}
int main()
{
    int max;
    while(cin>>str)
    {
        l=strlen(str);
        max=-1;
        for(i=0;i<l;i++)
            for(j=i;j<l;j++)
                if(sum(i,j)>max)
                    max=sum(i,j);
        cout<<max<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main ()
{
	string s;
	cin >> s;
	int ans = 0;
	int MAX = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == '+')
			ans++;
		else
			ans--;
		MAX = max(abs(ans),MAX);
	}
	cout << MAX << endl;
	return 0;
}


#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main ()
{
	string s;
	cin >> s;
	int ans = 1;
	int MAX = 0;
	for (int i = 1; i < s.length(); i++)
	{
		if (s[i] == s[i - 1])
			ans++;
		else
			ans = 1;
		MAX = max(ans,MAX);
	}
	cout << MAX << endl;
	return 0;
}


#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main ()
{
	string s;
	cin >> s;
	int ans = 1;
	int MAX = 1;
	for (int i = 1; i < s.length(); i++)
	{
		if (s[i] == s[i - 1])
			ans++;
		else
			ans = 1;
		MAX = max(ans,MAX);
	}
	cout << MAX << endl;
	return 0;
}


#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main ()
{
	string s;
	cin >> s;
	int ans = 0;
	int MAX = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == '+')
			ans++;
		else
			ans--;
		MAX = max(abs(ans),MAX);
	cout << abs(ans) << endl;
	return 0;
}


#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main ()
{
    string s;
    cin >> s;
    int ans = 0;
    int MAX = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == '+')
            ans++;
        else
            ans--;
        MAX = max(abs(ans),MAX);
    }
    ans = 1;
    for (int i = 1; i < s.length(); i++)
    {
        if (s[i] == s[i - 1])
            ans++;
        else
        {
            ans = 0;
            for (int j = i; j < s.length(); j++)
            {
                if (s[j] == '+')
                    ans++;
                else
                    ans--;
                MAX = max(abs(ans),MAX);
            }
            ans = 1;
        }
        MAX = max(ans,MAX);
    }
    cout << MAX << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main ()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.length(); i++)
		if (s[i] == '+')
			ans++;
		else
			ans--;
	cout << abs(ans) << endl;
	return 0;
}


#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main ()
{
	string s;
	cin >> s;
	int ans = 0;
	int MAX = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == '+')
			ans++;
		else
			ans--;
		MAX = max(abs(ans),MAX);
	}
	ans = 1;
	for (int i = 1; i < s.length(); i++)
	{
		if (s[i] == s[i - 1])
			ans++;
		else
			ans = 1;
		MAX = max(ans,MAX);
	}
	cout << MAX << endl;
	return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    int x=0,mx=0;
    string s; cin>>s;
    for(int i=0; i<(int)s.size(); ++i)
    {
        if(s[i]=='+')x++;
        else x--;
        mx=max(mx,abs(x));
    }
    cout<<mx;
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    int x=0,mx=0;
    string s; cin>>s;
    for(int j=0; j<s.size(); ++j)
    {
        x=0;
        for(int i=j; i<s.size(); ++i)
        {
            if(s[i]=='+')x++;
            else x--;
            mx=max(mx,abs(x));
        }
    }
    cout<<mx;
    return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    string s; cin>>s;
    int c=1,mx=1;
    s+="=";
    for(int i=1; i<s.size(); ++i)
    {
        if(s[i]==s[i-1])
            ++c;
        else
        {
            mx=max(c,mx);
            c=1;
        }
    }
    cout<<mx;
    return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int x=0,mx=0;
    string s; cin>>s;
    for(int j=0; j<s.size(); ++j)
    {
        x=0;
        for(int i=j; i<s.size(); )
        {
            if(s[i]=='+')x++;
            else x--;
            mx=max(mx,abs(x));
            ++i;
            i%=s.size();
        }
    }
    cout<<mx;
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    int x=0,mx=0;
    string s; cin>>s;
    for(int j=0; j<s.size(); ++j)
    {
        x=0;
        for(int i=j; i<s.size(); )
        {
            if(s[i]=='+')x++;
            else x--;
            mx=max(mx,abs(x));
            ++i;
            j%=s.size();
        }
    }
    cout<<mx;
    return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int x=0,mx=0;
    string s; cin>>s;
    for(int j=0; j<s.size(); ++j)
    {
        x=0;
        for(int i=j,k=0; k<s.size(); ++k)
        {
            if(s[i]=='+')x++;
            else x--;
            mx=max(mx,abs(x));
            ++i;
            i%=s.size();
        }
    }
    cout<<mx;
    return 0;
}


#pragma comment(linker, "/STACK:500000000")
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <time.h>
#include <set>
#include <utility>
using namespace std;
#define inf 0x3f3f3f3f
#define Int long long
#define eps 1e-9
#define pi acos(-1.0)

char A[333];

int main()
{
    scanf("%s", &A);
    int cntA = 0, cntB = 0;
    int len = strlen(A), i;
    for(i = 0; i < len; i++)
        if(A[i] == '-')
            cntA++;
        else
            cntB++;
    printf("%d\n", min(cntA, cntB) + abs(cntA - cntB));
}


#pragma comment(linker, "/STACK:500000000")
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <time.h>
#include <set>
#include <utility>
using namespace std;
#define inf 0x3f3f3f3f
#define Int long long
#define eps 1e-9
#define pi acos(-1.0)
#define N 5005

char A[333];

int main()
{
    int in = 0, out = 0;
    int res = 0;
    scanf("%s", &A);
    int len = strlen(A), i;
    for(i = 0; i < len; i++)
    {
        if(A[i] == '+')
        {
            if(out)
            {
                out--;
                in++;
            }
            else
            {
                in++;
                res++;
            }
        }
        else
        {
            if(in)
            {
                in--;
                out++;
            }
            else
            {
                out++;
                res++;
            }
        }
    }
    printf("%d\n", res);
}


#pragma comment(linker, "/STACK:500000000")
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <time.h>
#include <set>
#include <utility>
using namespace std;
#define inf 0x3f3f3f3f
#define Int long long
#define eps 1e-9
#define pi acos(-1.0)

char A[333];
stack <char> q;

int main()
{
    scanf("%s", &A);
    int len = strlen(A), i;
    q.push(A[0]);
    for(i = 1; i < len; i++)
        if(!q.empty() && A[i] != q.top())
            q.pop();
        else
            q.push(A[i]);
    printf("%d\n", (int)(q.size()));
}


#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <climits>

#if !defined(__GNUC__)
#include <hash_set>
#include <hash_map>

typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed long int32_t;
typedef unsigned long uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;

typedef stdext::hash_set<size_t>    hash_set_size_t;
#else // !defined(__GNUC__)

#endif // !defined(__GNUC__)

typedef long double double_t;
typedef std::string string8_t;

typedef std::vector<size_t> vector_size_t;
typedef std::vector<int32_t> vector_int32_t;
typedef std::vector<uint32_t> vector_uint32_t;
typedef std::set<size_t> set_size_t;
typedef std::multiset<size_t> multiset_size_t;

typedef std::vector<string8_t> vector_string8_t;
typedef std::set<string8_t> set_string8_t;
typedef std::multiset<std::string> multiset_string8_t;

// Auxiliary functions definition
//
template<typename T> inline T Abs(const T a) { return a < 0 ? -a : a; }
template<typename T> inline T Min(const T a, const T b) {return a < b ? a : b;}
template<typename T> inline T Max(const T a, const T b) {return a > b ? a : b;}
template<typename T> inline void UpdateMin(T& a, const T b) {a = Min(a, b);}
template<typename T> inline void UpdateMax(T& a, const T b) {a = Max(a, b);}

static const double_t eps = 1.0e-09;
template<typename T> inline bool IsEqual(const T a, const T b) { return Abs(a - b) < eps; }
template<typename T> inline bool IsGreater(const T a, const T b) { return a > b + eps; }
template<typename T> inline bool IsLess(const T a, const T b) { return a + eps < b; }

template<typename T> inline string8_t ToStr(const T& val) { std::ostringstream ostr; ostr << val; return ostr.str(); }
template<typename T> inline bool FromStr(const string8_t& str, T& val) {std::istringstream istr(str); istr >> val; return !!istr; }

#if defined(ONLINE_JUDGE) || defined(__GNUC__)
template<size_t id> class StopWatch { };
#else //defined(ONLINE_JUDGE)
#include <library/lib_stopwatch.h>
#endif //defined(ONLINE_JUDGE)

bool Solve(std::istream& ist, std::ostream& ost, const bool multipleTestMode)
{
    StopWatch<1> sw;

    // first input value
    string8_t s;
    ist >> s;

    if (multipleTestMode && !ist)
        return false;

    // remain input & solve
    int inside = 0;
    int outside = 0;
    int maxInside = 0;
    int maxOutside = 0;

    for (size_t i = 0; i < s.size(); i++)
    {
        if (s[i] == '+')
        {
            inside++;
            if (outside > 0)
                outside--;
        }
        else
        {
            outside++;
            if (inside > 0)
                inside--;
        }
        UpdateMax(maxInside, inside);
        UpdateMax(maxOutside, outside);
    }

    ost << Max(Abs(maxInside), Abs(maxOutside)) << std::endl;

    return multipleTestMode;
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::istream& ist = std::cin;
    std::ostream& ost = std::cout;
#if defined(ONLINE_JUDGE)
    Solve(ist, ost, false);
#else
    while(Solve(ist, ost, true)) {};
#endif
}


#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <climits>

#if !defined(__GNUC__)
#include <hash_set>
#include <hash_map>

typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed long int32_t;
typedef unsigned long uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;

typedef stdext::hash_set<size_t>    hash_set_size_t;
#else // !defined(__GNUC__)

#endif // !defined(__GNUC__)

typedef long double double_t;
typedef std::string string8_t;

typedef std::vector<size_t> vector_size_t;
typedef std::vector<int32_t> vector_int32_t;
typedef std::vector<uint32_t> vector_uint32_t;
typedef std::set<size_t> set_size_t;
typedef std::multiset<size_t> multiset_size_t;

typedef std::vector<string8_t> vector_string8_t;
typedef std::set<string8_t> set_string8_t;
typedef std::multiset<std::string> multiset_string8_t;

// Auxiliary functions definition
//
template<typename T> inline T Abs(const T a) { return a < 0 ? -a : a; }
template<typename T> inline T Min(const T a, const T b) {return a < b ? a : b;}
template<typename T> inline T Max(const T a, const T b) {return a > b ? a : b;}
template<typename T> inline void UpdateMin(T& a, const T b) {a = Min(a, b);}
template<typename T> inline void UpdateMax(T& a, const T b) {a = Max(a, b);}

static const double_t eps = 1.0e-09;
template<typename T> inline bool IsEqual(const T a, const T b) { return Abs(a - b) < eps; }
template<typename T> inline bool IsGreater(const T a, const T b) { return a > b + eps; }
template<typename T> inline bool IsLess(const T a, const T b) { return a + eps < b; }

template<typename T> inline string8_t ToStr(const T& val) { std::ostringstream ostr; ostr << val; return ostr.str(); }
template<typename T> inline bool FromStr(const string8_t& str, T& val) {std::istringstream istr(str); istr >> val; return !!istr; }

#if defined(ONLINE_JUDGE) || defined(__GNUC__)
template<size_t id> class StopWatch { };
#else //defined(ONLINE_JUDGE)
#include <library/lib_stopwatch.h>
#endif //defined(ONLINE_JUDGE)

bool Solve(std::istream& ist, std::ostream& ost, const bool multipleTestMode)
{
    StopWatch<1> sw;

    // first input value
    string8_t s;
    ist >> s;

    if (multipleTestMode && !ist)
        return false;

    // remain input & solve
    uint32_t inside = 0;
    uint32_t outside = 0;
    uint32_t maxInside = 0;
    uint32_t maxOutside = 0;

    for (size_t i = 0; i < s.size(); i++)
    {
        if (s[i] == '+')
        {
            inside++;
            if (outside > 0)
                outside--;
        }
        else
        {
            outside++;
            if (inside > 0)
                inside--;
        }
        UpdateMax(maxInside, inside);
        UpdateMax(maxOutside, outside);
    }

    ost << Max(maxInside, maxOutside) << std::endl;

    return multipleTestMode;
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::istream& ist = std::cin;
    std::ostream& ost = std::cout;
#if defined(ONLINE_JUDGE)
    Solve(ist, ost, false);
#else
    while(Solve(ist, ost, true)) {};
#endif
}


#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <climits>

#if !defined(__GNUC__)
#include <hash_set>
#include <hash_map>

typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed long int32_t;
typedef unsigned long uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;

typedef stdext::hash_set<size_t>    hash_set_size_t;
#else // !defined(__GNUC__)

#endif // !defined(__GNUC__)

typedef long double double_t;
typedef std::string string8_t;

typedef std::vector<size_t> vector_size_t;
typedef std::vector<int32_t> vector_int32_t;
typedef std::vector<uint32_t> vector_uint32_t;
typedef std::set<size_t> set_size_t;
typedef std::multiset<size_t> multiset_size_t;

typedef std::vector<string8_t> vector_string8_t;
typedef std::set<string8_t> set_string8_t;
typedef std::multiset<std::string> multiset_string8_t;

// Auxiliary functions definition
//
template<typename T> inline T Abs(const T a) { return a < 0 ? -a : a; }
template<typename T> inline T Min(const T a, const T b) {return a < b ? a : b;}
template<typename T> inline T Max(const T a, const T b) {return a > b ? a : b;}
template<typename T> inline void UpdateMin(T& a, const T b) {a = Min(a, b);}
template<typename T> inline void UpdateMax(T& a, const T b) {a = Max(a, b);}

static const double_t eps = 1.0e-09;
template<typename T> inline bool IsEqual(const T a, const T b) { return Abs(a - b) < eps; }
template<typename T> inline bool IsGreater(const T a, const T b) { return a > b + eps; }
template<typename T> inline bool IsLess(const T a, const T b) { return a + eps < b; }

template<typename T> inline string8_t ToStr(const T& val) { std::ostringstream ostr; ostr << val; return ostr.str(); }
template<typename T> inline bool FromStr(const string8_t& str, T& val) {std::istringstream istr(str); istr >> val; return !!istr; }

#if defined(ONLINE_JUDGE) || defined(__GNUC__)
template<size_t id> class StopWatch { };
#else //defined(ONLINE_JUDGE)
#include <library/lib_stopwatch.h>
#endif //defined(ONLINE_JUDGE)

bool Solve(std::istream& ist, std::ostream& ost, const bool multipleTestMode)
{
    StopWatch<1> sw;

    // first input value
    string8_t s;
    ist >> s;

    if (multipleTestMode && !ist)
        return false;

    // remain input & solve
    int x = 0;
    int minX = 0;
    int maxX = 0;

    for (size_t i = 0; i < s.size(); i++)
    {
        if (s[i] == '+')
            x++;
        else
            x--;
        UpdateMin(minX, x);
        UpdateMax(maxX, x);
    }

    ost << Max(Abs(minX), Abs(maxX)) << std::endl;

    return multipleTestMode;
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::istream& ist = std::cin;
    std::ostream& ost = std::cout;
#if defined(ONLINE_JUDGE)
    Solve(ist, ost, false);
#else
    while(Solve(ist, ost, true)) {};
#endif
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

#define int64 long long

#define maxn 100000

int f[maxn];
char str[maxn];
int len;
int cnt;
int ans=0;
int a,b,c;
struct Node
{
    int s,e;
}node[maxn];

bool cmp(const Node &a,const Node &b)
{
    return true;
}
int max(int a,int b){return a> b? a: b;}
int main()
{
    int n,m,i,j;
    gets(str);
    len=strlen(str);
    int minn=0;

    int ta=0; int tb=0;
    int it=-1;
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')it=i;
        else
        a=max(a,i-it);
    }
    it=-1;
    for(i=0;i<len;i++)
    {
        if(str[i]=='+')it=i;
        else
        b=max(b,i-it);
    }
    int st=0;
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')st+=1;
        else st-=1;
        minn=max(minn,abs(st));
    }

    printf("%d\n",max(minn,max(a,b)));
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

#define int64 long long

#define maxn 100000

int f[maxn];
char str[maxn];
int len;
int cnt;
int ans=0;
int a,b,c;
struct Node
{
    int s,e;
}node[maxn];

bool cmp(const Node &a,const Node &b)
{
    return true;
}
int max(int a,int b){return a> b? a: b;}
int main()
{
    int n,m,i,j;
    gets(str);
    len=strlen(str);
    int minn=0;
    int st=0;
    int ta=0; int tb=0;
    int it=-1;
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')it=i;
        else
        a=max(a,i-it);
    }
    it=-1;
    for(i=0;i<len;i++)
    {
        if(str[i]=='+')it=i;
        else
        b=max(b,i-it);
    }
    /*
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')st+=1;
        else st-=1;
        minn=max(minn,st);
    }
*/

    printf("%d\n",max(a,b));
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

#define int64 long long

#define maxn 100000

int f[maxn];
char str[maxn];
int len;
int cnt;
int ans=0;
int a,b,c;
struct Node
{
    int s,e;
}node[maxn];

bool cmp(const Node &a,const Node &b)
{
    return true;
}
int max(int a,int b){return a> b? a: b;}
int main()
{
    int n,m,i,j;
    gets(str);
    len=strlen(str);
    int minn=0;

    int ta=0; int tb=0;
    /*
    int it=-1;
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')it=i;
        else
        a=max(a,i-it);
    }
    it=-1;
    for(i=0;i<len;i++)
    {
        if(str[i]=='+')it=i;
        else
        b=max(b,i-it);
    }
    */
    int st=0;
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')st+=1;
        else st-=1;
        minn=max(minn,abs(st));
    }

    printf("%d\n",minn);//max(minn,max(a,b))
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

#define int64 long long

#define maxn 100000

int f[maxn];
char str[maxn];
int len;
int cnt;
int ans=0;
int a,b,c;
struct Node
{
    int s,e;
}node[maxn];

bool cmp(const Node &a,const Node &b)
{
    return true;
}
int max(int a,int b){return a> b? a: b;}
int main()
{
    int n,m,i,j;
    gets(str);
    len=strlen(str);
    int minn=0;

    int ta=0; int tb=0;
    /*
    int it=-1;
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')it=i;
        else
        a=max(a,i-it);
    }
    it=-1;
    for(i=0;i<len;i++)
    {
        if(str[i]=='+')it=i;
        else
        b=max(b,i-it);
    }
    */
    int st=0;
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')
        {
            tb++;
            if(ta>0)ta--;
        }
        else
        {
            ta++;
            if(tb>0)tb--;
        }
        minn=max(minn,ta+tb);
    }

    printf("%d\n",minn);//max(minn,max(a,b))
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

#define int64 long long

#define maxn 100000

int f[maxn];
char str[maxn];
int len;
int cnt;
int ans=0;
int a,b,c;
struct Node
{
    int s,e;
}node[maxn];

bool cmp(const Node &a,const Node &b)
{
    return true;
}
int abs(int x){return x>=0? x: -x;}
int max(int a,int b){return a> b? a: b;}
int main()
{
    int n,m,i,j;
    gets(str);
    len=strlen(str);
    int minn=0;

    int ta=0; int tb=0;
    /*
    int it=-1;
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')it=i;
        else
        a=max(a,i-it);
    }
    it=-1;
    for(i=0;i<len;i++)
    {
        if(str[i]=='+')it=i;
        else
        b=max(b,i-it);
    }
    */
    int st=0;
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')
        {
            tb++;
            if(ta>0)ta--;
        }
        else
        {
            ta++;
            if(tb>0)tb--;
        }
        minn=max(minn,ta+tb);
    }

    printf("%d\n",minn);//max(minn,max(a,b))
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	char prev = s[0];
	int count = 1;
	for(int i = 1; i<s.length(); i++)
	{
		if ( s[i] == prev)
		{
			count++;

		}
		prev = s[i];
	}
	cout << count << endl;
	return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int in =0 , out = 0;
	int count = 0;
	for(int i = 0; i<s.length(); i++)
	{
		if ( s[i] == '+' && out == 0){
			count++;
			in++;
		}
		else if ( s[i] == '+' && out > 0)

		{
			out--;
			in++;
		}
		else if (s[i] == '-' && in == 0)
		{
			count++;
			out++;
		}
		else if(s[i] == '-' && in >0)
		{
			in--;
			out++;
		}
	}
	cout << count << endl;
	return 0;
}


#define use_math__defines
#define _ert_no_deprecate

#include <stdlib.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <string>
#include <cstring>
#include <cmath>

int n, m[101][101], ma[101];

using namespace std;
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string str;
	cin >> str;
	str += " ";
	int i = 0;
	int pl = 0, mi = 0;
	do
	{
		if ( str[i] == '+')
			pl++;
		else
			++mi;
		++i;
	}
	while(str[i] != ' ');
	int ot = pl - mi;
	if (ot < 0)
		ot *= -1;
	cout << ot;
}


#define use_math__defines
#define _ert_no_deprecate

#include <stdlib.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <string>
#include <cstring>
#include <cmath>

int n, mn = 0, mp = 0;

using namespace std;
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string str;
	cin >> str;
	str += " ";
	int i = 0;
	int pl = 0, mi = 0;
	do
	{
		if ( str[i] == '+')
		{
			mp++;
			if (mn > 0)
				mn--;
		}
		else
		{
			++mn;
			if(mp > 0)
				--mp;
		}
		++i;
	}
	while(str[i] != ' ');
	cout << mp + mn;
}


// cf_245_e.cpp : Defines the entry point for the console application.
// By Andrew Moskalchuk (HorgH)

#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <map>
#include <set>
#pragma comment(linker,"/STACK:16777216")
using namespace std;

//Loops
#define FOR(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define ROF(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define rep(i,n) for (int (i) = 0; (i) < (n); ++(i))
#define fe(i,a) for (int (i) = 0; (i) < int((a).size()); ++(i))
#define MEM(a,b) memset((a),(b),sizeof(a))

//Constants
#define inf 1000000000
#define pi 2*acos(0.0)
#define N 100010
#define eps 1e-9

//Functions
#define pb push_back
#define ppb pop_back
#define all(c) (c).begin(), (c).end()
#define sz(x) int((x).size())
#define sqr(a) (a)*(a)

//Pairs
#define mp(a,b) make_pair((a), (b))
#define X first
#define Y second

//Input-Output
#define FREOPEN(a,b) freopen(a,"r",stdin); freopen(b,"w",stdout);

typedef vector<int> vint;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
    //FREOPEN("input.txt","output.txt");
    int n=0,ans=1,i,j,l,m=inf,c;
    string s;
    cin >> s;
    c=0;
    rep(i,sz(s))
    {
        if(s[i] == '+')c++; else c--;
        m=min(c,m);
    }
    FOR(i,1,-m)s="+"+s;
    m=0;
    for(i=0;i<sz(s);i++)
    {
        if(s[i] == '+')m++; else m--;
        ans=max(ans,m);
    }
    //cout << s << endl;
    printf("%d\n",ans);
    return 0;
}


// cf_245_e.cpp : Defines the entry point for the console application.
// By Andrew Moskalchuk (HorgH)
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <map>
#include <set>
#pragma comment(linker,"/STACK:16777216")
using namespace std;

//Loops
#define FOR(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define ROF(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define rep(i,n) for (int (i) = 0; (i) < (n); ++(i))
#define fe(i,a) for (int (i) = 0; (i) < int((a).size()); ++(i))
#define MEM(a,b) memset((a),(b),sizeof(a))

//Constants
#define inf 1000000000
#define pi 2*acos(0.0)
#define N 100010
#define eps 1e-9

//Functions
#define pb push_back
#define ppb pop_back
#define all(c) (c).begin(), (c).end()
#define sz(x) int((x).size())
#define sqr(a) (a)*(a)

//Pairs
#define mp(a,b) make_pair((a), (b))
#define X first
#define Y second

//Input-Output
#define FREOPEN(a,b) freopen(a,"r",stdin); freopen(b,"w",stdout);

typedef vector<int> vint;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
    //FREOPEN("input.txt","output.txt");
    int n=0,ans=0,i,j,l;
    string s;
    cin >> s;
    for(i=0;i<sz(s);i++)
    {
        if(s[i] == '+')
        {
            for(l=0;s[i] == '+' && i <sz(s);i++,l++);
        } else
        {
            for(l=0;s[i] == '-' && i< sz(s);i++,l++);
        }
        ans=max(ans,l);
        i--;
    }
    printf("%d\n",ans);
    return 0;
}


// cf_245_e.cpp : Defines the entry point for the console application.
// By Andrew Moskalchuk (HorgH)

#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <map>
#include <set>
#pragma comment(linker,"/STACK:16777216")
using namespace std;

//Loops
#define FOR(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define ROF(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define rep(i,n) for (int (i) = 0; (i) < (n); ++(i))
#define fe(i,a) for (int (i) = 0; (i) < int((a).size()); ++(i))
#define MEM(a,b) memset((a),(b),sizeof(a))

//Constants
#define inf 1000000000
#define pi 2*acos(0.0)
#define N 100010
#define eps 1e-9

//Functions
#define pb push_back
#define ppb pop_back
#define all(c) (c).begin(), (c).end()
#define sz(x) int((x).size())
#define sqr(a) (a)*(a)

//Pairs
#define mp(a,b) make_pair((a), (b))
#define X first
#define Y second

//Input-Output
#define FREOPEN(a,b) freopen(a,"r",stdin); freopen(b,"w",stdout);

typedef vector<int> vint;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
    //FREOPEN("input.txt","output.txt");
    int n=0,ans=0;
    string s;
    cin >> s;
    rep(i,sz(s))
    {
        if(s[i] == '+')n++; else n--;
        ans=max(ans,abs(n));
    }
    printf("%d\n",ans);
    return 0;
}


// cf_245_e.cpp : Defines the entry point for the console application.
// By Andrew Moskalchuk (HorgH)
//
#include "stdafx.h"

#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <map>
#include <set>
#pragma comment(linker,"/STACK:16777216")
using namespace std;

//Loops
#define FOR(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define ROF(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define rep(i,n) for (int (i) = 0; (i) < (n); ++(i))
#define fe(i,a) for (int (i) = 0; (i) < int((a).size()); ++(i))
#define MEM(a,b) memset((a),(b),sizeof(a))

//Constants
#define inf 1000000000
#define pi 2*acos(0.0)
#define N 100010
#define eps 1e-9

//Functions
#define pb push_back
#define ppb pop_back
#define all(c) (c).begin(), (c).end()
#define sz(x) int((x).size())
#define sqr(a) (a)*(a)

//Pairs
#define mp(a,b) make_pair((a), (b))
#define X first
#define Y second

//Input-Output
#define FREOPEN(a,b) freopen(a,"r",stdin); freopen(b,"w",stdout);

typedef vector<int> vint;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
    //FREOPEN("input.txt","output.txt");
    int n=0,ans=0,i,j,l;
    string s;
    cin >> s;
    for(i=0;i<sz(s);i++)
    {
        if(s[i] == '+')
        {
            for(l=0;s[i] == '+' && i <sz(s);i++,l++);
        } else
        {
            for(l=0;s[i] == '-' && i< sz(s);i++,l++);
        }
        ans=max(ans,l);
        i--;
    }
    printf("%d\n",ans);
    return 0;
}


// cf_245_e.cpp : Defines the entry point for the console application.
// By Andrew Moskalchuk (HorgH)

#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <map>
#include <set>
#pragma comment(linker,"/STACK:16777216")
using namespace std;

//Loops
#define FOR(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define ROF(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define rep(i,n) for (int (i) = 0; (i) < (n); ++(i))
#define fe(i,a) for (int (i) = 0; (i) < int((a).size()); ++(i))
#define MEM(a,b) memset((a),(b),sizeof(a))

//Constants
#define inf 1000000000
#define pi 2*acos(0.0)
#define N 100010
#define eps 1e-9

//Functions
#define pb push_back
#define ppb pop_back
#define all(c) (c).begin(), (c).end()
#define sz(x) int((x).size())
#define sqr(a) (a)*(a)

//Pairs
#define mp(a,b) make_pair((a), (b))
#define X first
#define Y second

//Input-Output
#define FREOPEN(a,b) freopen(a,"r",stdin); freopen(b,"w",stdout);

typedef vector<int> vint;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
    //FREOPEN("input.txt","output.txt");
    int n=0,ans=1,i,j,l,m=inf,c;
    string s;
    cin >> s;
    c=0;
    rep(i,sz(s))
    {
        if(s[i] == '+')c++; else c--;
        m=min(c,m);
    }
    FOR(i,1,-m)s="+"+s;
    m=1;
    for(i=1;i<sz(s);i++)
    {
        if(s[i] != s[i-1])m=1; else m++;
        ans=max(ans,m);
    }
    printf("%d\n",ans);
    return 0;
}


// cf_245_e.cpp : Defines the entry point for the console application.
// By Andrew Moskalchuk (HorgH)

#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <map>
#include <set>
#pragma comment(linker,"/STACK:16777216")
using namespace std;

//Loops
#define FOR(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define ROF(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define rep(i,n) for (int (i) = 0; (i) < (n); ++(i))
#define fe(i,a) for (int (i) = 0; (i) < int((a).size()); ++(i))
#define MEM(a,b) memset((a),(b),sizeof(a))

//Constants
#define inf 1000000000
#define pi 2*acos(0.0)
#define N 100010
#define eps 1e-9

//Functions
#define pb push_back
#define ppb pop_back
#define all(c) (c).begin(), (c).end()
#define sz(x) int((x).size())
#define sqr(a) (a)*(a)

//Pairs
#define mp(a,b) make_pair((a), (b))
#define X first
#define Y second

//Input-Output
#define FREOPEN(a,b) freopen(a,"r",stdin); freopen(b,"w",stdout);

typedef vector<int> vint;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
    //FREOPEN("input.txt","output.txt");
    int n=0,ans=1,i,j,l,m;
    string s;
    cin >> s;
    m=1;
    for(i=1;i<sz(s);i++)
    {
        if(s[i] != s[i-1])m=1; else m++;
        ans=max(ans,m);
    }
    printf("%d\n",ans);
    return 0;
}


#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<cstdio>
#include<bitset>
using namespace std;

#define FilesX
#define TimeX
#define DEBUG

#ifdef DEBUG
#define DBG(x,s) cout<<s<<": "#x"="<<x<<"\n";
#else
#define DBG(x,s)
#endif
#define P(x) cout<<#x<<" = { "<<x<<" }\n"
#define All(a) (a).begin(), (a).end()
#define rep(i,n) for(int i=0;i<int(n);i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define repi(i,a,n) for(int i=int(a);i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define clr(a, n) memset(a, n, sizeof(a));
#define scn(a,n) rep(i,n) cin>>a[i];
#define scn2(a,row,col) rep(i,row) rep(j,col) cin>>a[i][j];
#define prn(a,n) rep(i,n-1) cout<<a[i]<<" "; cout<<a[n-1]<<endl;
#define prn2(a,row,col) rep(i,row){rep(j,col-1) cout<<a[i][j]<<" "; cout<<a[i][col-1]<<endl;}
#define dri(x) scanf("%d",&(x))
#define drii(x,y) scanf("%d%d",&(x),&(y))
#define drl(x) scanf("%I64d",&(x))
#define drll(x,y) scanf("%I64d%I64d",&(x),&(y))
#define mp(a, b) make_pair(a, b)
#define Odd(x) x%2!=0
#define Even(x) x%2==0
#define PI 3.1415926535897932384626433832795
#define INF 20000000000ll
const double EPS = (1e-7);
int dcmp(double x, double y) {  return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;   }

typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, string> is;
typedef vector<pii> vii;

ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }

/*---------------------------*/

void solution(){
	string s;
	cin>>s;
	int res = 0, now = 0;
	rep(i, s.length()){
		if (s[i] == '-') now--;
		else now++;
		res = min(res, now);
	}
	cout<<max(abs(res), now);
}

//*---------------------------*/
int main(){
	#ifdef Files
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	double beg=clock();

	ios::sync_with_stdio(false);
	solution();

	#ifdef Time
	cout << endl;
	double end=clock();
	printf("*** Total time = %.3f sec ***", (end - beg) / CLOCKS_PER_SEC);
	#endif
	return 0;
}


#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<cstdio>
#include<bitset>
using namespace std;

#define FilesX
#define TimeX
#define DEBUG

#ifdef DEBUG
#define DBG(x,s) cout<<s<<": "#x"="<<x<<"\n";
#else
#define DBG(x,s)
#endif
#define P(x) cout<<#x<<" = { "<<x<<" }\n"
#define All(a) (a).begin(), (a).end()
#define rep(i,n) for(int i=0;i<int(n);i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define repi(i,a,n) for(int i=int(a);i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define clr(a, n) memset(a, n, sizeof(a));
#define scn(a,n) rep(i,n) cin>>a[i];
#define scn2(a,row,col) rep(i,row) rep(j,col) cin>>a[i][j];
#define prn(a,n) rep(i,n-1) cout<<a[i]<<" "; cout<<a[n-1]<<endl;
#define prn2(a,row,col) rep(i,row){rep(j,col-1) cout<<a[i][j]<<" "; cout<<a[i][col-1]<<endl;}
#define dri(x) scanf("%d",&(x))
#define drii(x,y) scanf("%d%d",&(x),&(y))
#define drl(x) scanf("%I64d",&(x))
#define drll(x,y) scanf("%I64d%I64d",&(x),&(y))
#define mp(a, b) make_pair(a, b)
#define Odd(x) x%2!=0
#define Even(x) x%2==0
#define PI 3.1415926535897932384626433832795
#define INF 20000000000ll
const double EPS = (1e-7);
int dcmp(double x, double y) {  return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;   }

typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, string> is;
typedef vector<pii> vii;

ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }

/*---------------------------*/

void solution(){
	string s;
	cin>>s;
	int res = 0, now = 0, mx = 0, mn = 0;
	rep(i, s.length()){
		if (s[i] == '-') now--;
		else now++;
		mx = max(mx, now);
		mn = min(mn, now);
	}
	cout<<mx + abs(mn);
}

//*---------------------------*/
int main(){
	#ifdef Files
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	double beg=clock();

	ios::sync_with_stdio(false);
	solution();

	#ifdef Time
	cout << endl;
	double end=clock();
	printf("*** Total time = %.3f sec ***", (end - beg) / CLOCKS_PER_SEC);
	#endif
	return 0;
}


#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<cstdio>
#include<bitset>
using namespace std;

#define FilesX
#define TimeX
#define DEBUG

#ifdef DEBUG
#define DBG(x,s) cout<<s<<": "#x"="<<x<<"\n";
#else
#define DBG(x,s)
#endif
#define P(x) cout<<#x<<" = { "<<x<<" }\n"
#define All(a) (a).begin(), (a).end()
#define rep(i,n) for(int i=0;i<int(n);i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define repi(i,a,n) for(int i=int(a);i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define clr(a, n) memset(a, n, sizeof(a));
#define scn(a,n) rep(i,n) cin>>a[i];
#define scn2(a,row,col) rep(i,row) rep(j,col) cin>>a[i][j];
#define prn(a,n) rep(i,n-1) cout<<a[i]<<" "; cout<<a[n-1]<<endl;
#define prn2(a,row,col) rep(i,row){rep(j,col-1) cout<<a[i][j]<<" "; cout<<a[i][col-1]<<endl;}
#define dri(x) scanf("%d",&(x))
#define drii(x,y) scanf("%d%d",&(x),&(y))
#define drl(x) scanf("%I64d",&(x))
#define drll(x,y) scanf("%I64d%I64d",&(x),&(y))
#define mp(a, b) make_pair(a, b)
#define Odd(x) x%2!=0
#define Even(x) x%2==0
#define PI 3.1415926535897932384626433832795
#define INF 20000000000ll
const double EPS = (1e-7);
int dcmp(double x, double y) {  return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;   }

typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, string> is;
typedef vector<pii> vii;

ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }

/*---------------------------*/

void solution(){
	string s;
	cin>>s;
	int res = -1, now = 0;
	rep(i, s.length()){
		if (s[i] == '-') now--;
		else now++;
		res = max(res, abs(now));
	}
	cout<<res;
}

//*---------------------------*/
int main(){
	#ifdef Files
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	double beg=clock();

	ios::sync_with_stdio(false);
	solution();

	#ifdef Time
	cout << endl;
	double end=clock();
	printf("*** Total time = %.3f sec ***", (end - beg) / CLOCKS_PER_SEC);
	#endif
	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	string s;
	cin>>s;
	s+='0';
	int len = s.length();
	int kol=1;
	int Mkol = 1;
	if(len==1)
	{
		cout<<1<<endl;
		return 0;
	}

	for(int i=1; i<len; i++)
	{
		if(s[i]==s[i-1])
		{
			kol++;
		}
		else
		{
			if(kol>Mkol)
			{
				Mkol=kol;
			}
			kol=1;
		}

	}

	cout<<Mkol<<endl;
	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	string s;
	cin>>s;
	int len = s.length();
	int kol=0;
	int Mkol = 0;
	if(len==1)
	{
		cout<<1<<endl;
		return 0;
	}

	for(int i=0; i<len; i++)
	{
		if(s[i]=='+')
		{
			kol++;
			Mkol = max(Mkol-1, 0);
		}
		else
		{
			Mkol++;
			kol = max(kol-1, 0);
		}
	}

	cout<<Mkol+kol<<endl;
	return 0;
}


#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<vector>
using namespace std;

typedef pair<int,int> p;

int main()
{
    char s[500];
    int i,cnt1,cnt2,ans;
    while(scanf("%s",s) != EOF)
    {
        cnt1 = cnt2 = ans = 0;
        for(i = 0;i < strlen(s);i ++)
        {
            if(s[i] == '+')
                cnt1 ++;
            else
            {
                if(cnt1 > 0)
                {
                    cnt1 --;
                }
                else
                    cnt2 ++;
            }
        }
        printf("%d\n",abs(cnt1 - cnt2));
    }
    return 0;
}