#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while (!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
double get_time() { return 1.0 * clock() / CLOCKS_PER_SEC; }
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int sum = 0;
  int prev = 0;
  vector<vector<int>> vec;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    vector<int> temp;
    if (sum == 0 || i == n - 1) {
      for (int j = prev; j <= i; j++) {
        temp.push_back(a[j]);
      }
      if (!temp.empty()) vec.push_back(temp);
      prev = i + 1;
    }
  }
  if (sum == 0) {
    cout << "NO" << '\n';
    return;
  }
  sum = 0;
  vector<int> res;
  for (int x : vec.back()) {
    sum += x;
    res.push_back(x);
  }
  for (int i = 0; i < (int)vec.size() - 1; i++) {
    if (sum > 0)
      sort(vec[i].begin(), vec[i].end(), greater<int>());
    else
      sort(vec[i].begin(), vec[i].end());
    for (int x : vec[i]) res.push_back(x);
  }
  cout << "YES" << '\n';
  for (int x : res) cout << x << ' ';
  cout << '\n';
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
