#include <iostream>
#include <vector>
#include <set>
using namespace std;
void solve() {
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
vector<long long> a(n);
long long specialIndex = -1;
for (long long i = 0; i < n; i++) {
cin >> a[i];
if (a[i] != 1 && a[i] != -1) {
specialIndex = i;
}
}
vector<long long> prefixSum(n + 1, 0);
for (long long i = 0; i < n; i++) {
prefixSum[i + 1] = prefixSum[i] + a[i];
}
set<long long> result;
result.insert(0);
for (long long i = 0; i <= n; i++) {
for (long long j = i + 1; j <= n; j++) {
result.insert(prefixSum[j] - prefixSum[i]);
}
}
if (specialIndex != -1) {
long long x = a[specialIndex];
for (long long i = 0; i <= specialIndex; i++) {
for (long long j = specialIndex + 1; j <= n; j++) {
long long sumWithoutX = prefixSum[specialIndex] - prefixSum[i];
long long sumWithX = sumWithoutX + x + (prefixSum[j] - prefixSum[specialIndex + 1]);
result.insert(sumWithX);
}
}
}
cout << result.size() << '\n';
for (long long s : result) {
cout << s << ' ';
}
cout << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}