#include int main(){ int D; scanf("%d", &D); int a[10001]; for(int i=0;i<=D;i++){scanf("%d", a+i);} for(int i=D-3;i>=0;i--){ a[i+1] += a[i+3]; a[i+3] = 0; } int d = 0; for(int i=0;i<=D;i++){ if(a[i] > 0){d = i;} } printf("%d\n", d); for(int i=0;i<=d;i++){ if(i == d){printf("%d\n", a[i]);} else{printf("%d ", a[i]);} } }