#include <bits/stdc++.h>
using namespace std;
int n, q, fa[100005], u, v;
double ans, pb[100005], sum[100005];
struct tree {
  int v;
  tree *next;
} * h[100005], pool[100005 << 1], *tot = pool;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void addedge(int u, int v) {
  tree *p = tot++;
  p->v = v;
  p->next = h[u];
  h[u] = p;
}
void dfs(int u, int f) {
  fa[u] = f;
  ans += pb[fa[u]] * (1 - pb[u]);
  for (tree *p = h[u]; p; p = p->next)
    if (p->v != f) {
      dfs(p->v, u);
      sum[u] += (1 - pb[p->v]);
    }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) scanf("%lf", &pb[i]);
  for (int i = 1; i < n; i++) {
    u = read();
    v = read();
    u++;
    v++;
    addedge(u, v);
    addedge(v, u);
  }
  pb[0] = 1;
  dfs(1, 0);
  q = read();
  for (int i = 1; i <= q; i++) {
    double del;
    u = read();
    scanf("%lf", &del);
    u++;
    ans += pb[fa[u]] * (1 - del) - pb[fa[u]] * (1 - pb[u]);
    ans += del * sum[u] - pb[u] * sum[u];
    sum[fa[u]] += -del + pb[u];
    pb[u] = del;
    printf("%.5lf\n", ans);
  }
  return 0;
}
