#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> vec[200002];
int col[200002];
int flag = 0;
int k = -1;
int visited[200002];
int over = 1;
int cnt;
int dfs(int x) {
  int fl = 0;
  visited[x] = 1;
  cnt--;
  if (over == 1) {
    over = 0;
  } else
    col[x]++;
  if (x != 1 && vec[x].size() == 1 && (col[x] & 1) == 1) {
    printf(" %d", x);
    return 1;
  }
  if (flag) {
    printf(" ");
  }
  flag = 1;
  printf("%d", x);
  for (int i = 0; i < vec[x].size(); i++) {
    if (!visited[vec[x][i]]) {
      if (dfs(vec[x][i]) == 1) {
        if (flag) {
          printf(" ");
        }
        printf("%d %d", x, vec[x][i]);
        col[x]++;
        col[vec[x][i]]++;
        flag = 1;
      }
      if (flag) {
        printf(" ");
      }
      if (cnt == 0 && x == 1 && (col[x] & 1) == 0) {
      } else {
        printf("%d", x);
        col[x]++;
        flag = 1;
      }
    }
  }
  if ((col[x] & 1) == 0) {
    return 0;
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  memset(visited, 0, sizeof(visited));
  int label = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", col + i);
    if (col[i] == 1) {
      col[i] = 0;
    } else {
      col[i] = 1;
      label = 0;
    }
  }
  int x, y;
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &x, &y);
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  if (label == 0) {
    cnt = n;
    dfs(1);
    printf("\n");
  } else {
    printf("1\n");
  }
}
