1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <iostream>
using namespace std;
unsigned int* read_input(std::istream& input, long long &n) 
{
	unsigned int num;
	input >> n;
	unsigned int* array = new unsigned int[n];
	for(int i=0; i<n; i++) {
		input >> num;
		array[i] = num;  
	}
	return array;
}

bool is_valid_tree(unsigned int* arr, long long n) {
	long long sum = 0;
	long long num_of_ones = 0;
	for(int i =0; i < n; i++) {
		sum += arr[i];
		if(arr[i] == 1) {
			num_of_ones ++;
		}
	}
	if((sum == 2*(n-1)) && (num_of_ones >= 2)) {
		return true;
	}
	return false;
}

#ifndef TEST
int main(int argc, char* argv[]) {
#else
int _main(int argc, char* argv[]) {
#endif
	long long n;
	unsigned int* arr = read_input(cin, n);
	if(is_valid_tree(arr, n)) {
		printf("0\n2\n1 2\n");
	}
	else {
	
	}
	delete[] arr;
}