#include #include int main() { long long n; std::cin >> n; std::vector b(n); for (int i = 0; i < n; i++) { std::cin >> b[i]; } if (n == 1 && b[0] == 1) { std::cout << -1 << std::endl; return 0; } int miss_count = 0; std::vector a(n + 1, 0); a[0] = 1; for (int i = 0; i < n; i++) { if (i % 2 == 0) { a[i + 1] = b[i] - a[i]; } else { a[i + 1] = a[i] - b[i]; } if (a[i + 1] <= 0 || a[i + 1] > 1000000000000000000) { a[0] += -a[i + 1] + 1; i = -1; miss_count++; } if (miss_count == 10000) { std::cout << -1 << std::endl; return 0; } } std::cout << a.size() << std::endl; for (int i = 0; i < n + 1; i++) { std::cout << a[i] << std::endl; } return 0; }