```go
package main
import (
"bufio"
"fmt"
"os"
)
var n int
var col []int
var adj [][]int
var res []int
func dfs(u, p int) {
for _, v := range adj[u] {
if v != p {
res = append(res, v)
col[v] ^= 1
dfs(v, u)
res = append(res, u)
col[u] ^= 1
}
}
if col[u] == 1 {
if p != 0 {
res = append(res, p)
res = append(res, u)
col[p] ^= 1
col[u] ^= 1
}
}
}
func main() {
sc := bufio.NewReader(os.Stdin)
fmt.Fscan(sc, &n)
col = make([]int, n+1)
for i := 1; i <= n; i++ {
var c int
fmt.Fscan(sc, &c)
if c == -1 {
col[i] = 1
} else {
col[i] = 0
}
}
adj = make([][]int, n+1)
for i := 0; i < n-1; i++ {
var u, v int
fmt.Fscan(sc, &u, &v)
adj[u] = append(adj[u], v)
adj[v] = append(adj[v], u)
}
res = append(res, 1)
col[1] ^= 1
dfs(1, 0)
if col[1] == 1 && len(adj[1]) > 0 {
v := adj[1][0]
res = append(res, v)
res = append(res, 1)
col[v] ^= 1
col[1] ^= 1
}
fmt.Println(len(res))
for i, x := range res {
if i > 0 {
fmt.Print(" ")
}
fmt.Print(x)
}
fmt.Println()
}
```