#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
int main() {
int t;
cin >> t;
while(t--){
ll n, find = 0, a = 0, b = 0, c = 0, d = 0, sa = 0, sb = 0, sc = 0, sd = 0;
cin >> n;
vector<int> v(n);
set <int> s;
for(int i = 0; i < n; i++){
cin >> v[i];
if(v[i] != 1 && v[i] != -1){
find = i;
}
}
for(int i = 0; i < find; i++){
sa = max(0ll, sa + v[i]);
sb = min(0ll, sb + v[i]);
a = max(a, sa);
b = min(b, sb);
}
for(int i = find + 1; i < n; i++){
sc = max(0ll, sc + v[i]);
sd = min(0ll, sd + v[i]);
c = max(c, sc);
d = min(d, sd);
}
for(int i = min(b, d); i <= max(a,c); i++){
s.insert(i);
}
a = 0, b = 0, c = 0, d = 0, sa = 0, sb = 0, sc = 0, sd = 0;
for(int i = find - 1; i >= 0; i--){
sa += v[i];
sb += v[i];
a = max(a, sa);
b = min(b, sb);
}
for(int i = find + 1; i < n; i++){
sc += v[i];
sd += v[i];
c = max(c, sc);
d = min(d, sd);
}
for(int i = v[find] + b + d; i <= v[find] + a + c; i++){
s.insert(i);
}
cout << s.size() << endl;
for(auto u: s)cout << u << " ";
cout << endl;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c2V0Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCmludCBtYWluKCkgewogICAgaW50IHQ7CiAgICBjaW4gPj4gdDsKICAgIHdoaWxlKHQtLSl7CiAgICAgICAgbGwgbiwgZmluZCA9IDAsIGEgPSAwLCBiID0gMCwgYyA9IDAsIGQgPSAwLCBzYSA9IDAsIHNiID0gMCwgc2MgPSAwLCBzZCA9IDA7CiAgICAgICAgY2luID4+IG47CiAgICAgICAgdmVjdG9yPGludD4gdihuKTsKICAgICAgICBzZXQgPGludD4gczsKICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKICAgICAgICAgICAgY2luID4+IHZbaV07CiAgICAgICAgICAgIGlmKHZbaV0gIT0gMSAmJiB2W2ldICE9IC0xKXsKICAgICAgICAgICAgICAgIGZpbmQgPSBpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCBmaW5kOyBpKyspewogICAgICAgICAgICBzYSA9IG1heCgwbGwsIHNhICsgdltpXSk7CiAgICAgICAgICAgIHNiID0gbWluKDBsbCwgc2IgKyB2W2ldKTsKICAgICAgICAgICAgYSA9IG1heChhLCBzYSk7CiAgICAgICAgICAgIGIgPSBtaW4oYiwgc2IpOwogICAgICAgIH0KICAgICAgICBmb3IoaW50IGkgPSBmaW5kICsgMTsgaSA8IG47IGkrKyl7CiAgICAgICAgICAgIHNjID0gbWF4KDBsbCwgc2MgKyB2W2ldKTsKICAgICAgICAgICAgc2QgPSBtaW4oMGxsLCBzZCArIHZbaV0pOwogICAgICAgICAgICBjID0gbWF4KGMsIHNjKTsKICAgICAgICAgICAgZCA9IG1pbihkLCBzZCk7CiAgICAgICAgfQogICAgICAgIGZvcihpbnQgaSA9IG1pbihiLCBkKTsgaSA8PSBtYXgoYSxjKTsgaSsrKXsKICAgICAgICAgICAgcy5pbnNlcnQoaSk7CiAgICAgICAgfQogICAgICAgIGEgPSAwLCBiID0gMCwgYyA9IDAsIGQgPSAwLCBzYSA9IDAsIHNiID0gMCwgc2MgPSAwLCBzZCA9IDA7CiAgICAgICAgZm9yKGludCBpID0gZmluZCAtIDE7IGkgPj0gMDsgaS0tKXsKICAgICAgICAgICAgc2EgKz0gdltpXTsKICAgICAgICAgICAgc2IgKz0gdltpXTsKICAgICAgICAgICAgYSA9IG1heChhLCBzYSk7CiAgICAgICAgICAgIGIgPSBtaW4oYiwgc2IpOwogICAgICAgIH0KICAgICAgICBmb3IoaW50IGkgPSBmaW5kICsgMTsgaSA8IG47IGkrKyl7CiAgICAgICAgICAgIHNjICs9IHZbaV07CiAgICAgICAgICAgIHNkICs9IHZbaV07CiAgICAgICAgICAgIGMgPSBtYXgoYywgc2MpOwogICAgICAgICAgICBkID0gbWluKGQsIHNkKTsKICAgICAgICB9CiAgICAgICAgZm9yKGludCBpID0gdltmaW5kXSArIGIgKyBkOyBpIDw9IHZbZmluZF0gKyBhICsgYzsgaSsrKXsKICAgICAgICAgICAgcy5pbnNlcnQoaSk7CiAgICAgICAgfQogICAgICAgIGNvdXQgPDwgcy5zaXplKCkgPDwgZW5kbDsKICAgICAgICBmb3IoYXV0byB1OiBzKWNvdXQgPDwgdSA8PCAiICI7CiAgICAgICAgY291dCA8PCBlbmRsOwogICAgfQp9