#include <bits/stdc++.h>
using namespace std;
int t1, n, tot, e[200010], hd[200010], nt[200010], pa[200010];
double a[200010], son[200010], b[200010], ans;
void build(int x, int y) {
  tot++;
  e[tot] = y;
  nt[tot] = hd[x];
  hd[x] = tot;
}
void dfs(int x, int fa) {
  int i;
  pa[x] = fa;
  son[x] = 0;
  for (i = hd[x]; i; i = nt[i]) {
    if (e[i] == fa) continue;
    son[x]++;
    dfs(e[i], x);
  }
}
int main() {
  int i, x, y;
  double w;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%lf", &a[i]);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    x++;
    y++;
    build(x, y);
    build(y, x);
  }
  ans = 1.0 - a[1];
  dfs(1, 0);
  for (i = 2; i <= n; i++) b[pa[i]] += a[i], ans += (1.0 - a[i]) * a[pa[i]];
  a[0] = 1;
  scanf("%d", &t1);
  while (t1--) {
    scanf("%d%lf", &x, &w);
    x++;
    ans -= (1.0 - a[x]) * a[pa[x]];
    ans -= a[x] * (son[x] - b[x]);
    b[pa[x]] -= a[x];
    a[x] = w;
    ans += (1.0 - a[x]) * a[pa[x]];
    ans += a[x] * (son[x] - b[x]);
    b[pa[x]] += a[x];
    printf("%.13lf\n", ans);
  }
}
