#include <bits/stdc++.h>
int n;
double p[1000005], ans, sum[1000005];
int head[1000005], tot, fa[1000005];
struct edge {
  int nxt, v;
} e[1000005 << 1];
inline void addedge(int u, int v) {
  e[++tot] = (edge){head[u], v};
  head[u] = tot;
}
inline void dfs(int u, int Fa) {
  ans += (1 - p[Fa]) * p[u];
  fa[u] = Fa;
  for (int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v) {
    if (v == Fa) continue;
    dfs(v, u);
    sum[u] += p[v];
  }
}
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) {
    int u, v;
    scanf("%d %d", &u, &v);
    ++u;
    ++v;
    addedge(u, v);
    addedge(v, u);
  }
  dfs(1, 0);
  int q;
  scanf("%d", &q);
  while (q--) {
    int x;
    double px;
    scanf("%d %lf", &x, &px);
    ++x;
    px = 1 - px;
    ans -= p[x] * (1 - p[fa[x]]) + (1 - p[x]) * sum[x];
    sum[fa[x]] -= p[x];
    p[x] = px;
    ans += p[x] * (1 - p[fa[x]]) + (1 - p[x]) * sum[x];
    sum[fa[x]] += p[x];
    printf("%lf\n", ans);
  }
}
