#include <bits/stdc++.h>
const int mn = 110000;
int n, xx, yy, be[mn], et, q, fa[mn];
double p[mn], ans, f[mn], pp;
struct edg {
  int y, ne;
};
edg e[mn * 2];
inline void add_edge(int x, int y) {
  e[++et].y = y;
  e[et].ne = be[x];
  be[x] = et;
}
void dfs(int x, int ff) {
  fa[x] = ff;
  for (int i = be[x]; i; i = e[i].ne)
    if (e[i].y != ff) {
      dfs(e[i].y, x);
      f[x] += p[e[i].y];
    }
  ans += p[x] * (1 - f[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &p[i]);
    p[i] = 1 - p[i];
  }
  for (int i = 2; i <= n; i++) {
    scanf("%d%d", &xx, &yy);
    xx++;
    yy++;
    add_edge(xx, yy);
    add_edge(yy, xx);
  }
  dfs(1, -1);
  scanf("%d", &q);
  while (q--) {
    scanf("%d%lf", &xx, &pp);
    xx++;
    pp = 1 - pp;
    ans += (pp - p[xx]) * (1 - f[xx]);
    if (fa[xx] > 0) {
      int &ff = fa[xx];
      ans += (-pp + p[xx]) * p[ff];
      f[ff] += pp - p[xx];
    }
    p[xx] = pp;
    printf("%.10f\n", ans);
  }
  return 0;
}
