Code : Absolute Zero
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve(vector<int> &a) {
int n = a.size();
vector<int> seq;
for (int i = 0; i < 39; i++) {
int mx = *max_element(a.begin(), a.end());
int mid = (0 + mx) / 2;
for (auto &ele : a) {
ele = abs(ele - mid);
}
seq.push_back(mid);
}
int remain = a.front();
seq.push_back(remain);
for (auto &ele : a) {
ele = abs(ele - remain);
}
if (*max_element(a.begin(), a.end()) == 0) {
cout << 40 << "\n";
for (auto &ele : seq) {
cout << ele << " ";
}
cout << "\n";
} else {
cout << "-1"
<< "\n";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
for (int zz = 0; zz < t; zz++) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
solve(a);
}
}