#if __has_include("../stdc++.h")
#include "../stdc++.h"
#else
#include <bits/stdc++.h>
#endif
template <typename T>
std::istream &operator>>(std::istream &in, std::vector<T> &v)
{
for (T &x : v)
in >> x;
return in;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v)
{
for (std::size_t i = 0; i < v.size(); ++i)
out << v[i] << (i + 1 == v.size() ? "" : " ");
return out;
}
inline void yes() { std::cout << "Yes\n"; }
inline void no() { std::cout << "No\n"; }
using namespace std;
void solve()
{
int n;
cin >> n;
vector<long long> a(n);
cin >> a;
sort(a.begin(), a.end(), greater<long long>());
long long curr = 0;
curr += a[0];
curr -= a[1];
for (int i = 2; i < n; i++) {
if (a[i] <= 0) break;
if (i % 2 == 0) {
if (a[i] > 0) {
curr += a[i];
}
} else {
if (curr - a[i] < curr) {
curr -= a[i];
}
}
}
cout << max(curr, a[0] - a[1]) << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}