#include <bits/stdc++.h>
using namespace std;
double ans, p[100005], sum[100005];
int n, tot, Q, fa[100005];
struct edge {
  int v;
  edge *next;
} pool[100005 << 1], *h[100005];
void addedge(int u, int v) {
  edge *q = &pool[tot++];
  q->v = v;
  q->next = h[u];
  h[u] = q;
}
void dfs(int u, int f) {
  fa[u] = f;
  for (edge *q = h[u]; q; q = q->next)
    if (q->v != f) dfs(q->v, u), sum[u] += 1 - p[q->v];
}
int main() {
  scanf("%d", &n);
  p[n] = 1;
  for (int i = 0; i < n; i++) scanf("%lf", &p[i]);
  for (int i = 1, u, v; i < n; i++)
    scanf("%d %d", &u, &v), addedge(u, v), addedge(v, u);
  dfs(0, n);
  ans = 1 - p[0];
  for (int i = 1; i < n; i++) ans = ans + (1 - p[i]) * p[fa[i]];
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    int x;
    double pnw;
    scanf("%d %lf", &x, &pnw);
    ans += (p[x] - pnw) * p[fa[x]];
    ans += (pnw - p[x]) * sum[x];
    printf("%.5lf\n", ans);
    sum[fa[x]] += p[x] - pnw;
    p[x] = pnw;
  }
  return 0;
}
