#include <bits/stdc++.h>
using namespace std;
int const N = 1e5 + 20;
int n, tot = 0, fa[N], u, v, q, x;
double p, w[N], sum1 = 0, sum2 = 0, sw[N];
struct P {
  int to, next;
} f[N * 2];
int head[N];
void insert(int u, int v) {
  f[++tot].to = v;
  f[tot].next = head[u];
  head[u] = tot;
}
void dfs(int u, int v) {
  fa[u] = v;
  sw[u] = 0;
  for (int i = head[u]; i; i = f[i].next) {
    int j = f[i].to;
    if (j == v) continue;
    sw[u] += w[j];
    dfs(j, u);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &p);
    w[i] = 1.0 - p;
    sum1 += w[i];
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    insert(u + 1, v + 1);
    insert(v + 1, u + 1);
    sum2 += w[u + 1] * w[v + 1];
  }
  dfs(1, 0);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%lf", &x, &p);
    x++;
    p = 1 - p;
    sum1 = sum1 - w[x] + p;
    sw[fa[x]] += -w[x] + p;
    sum2 = sum2 - w[x] * sw[x] - w[x] * w[fa[x]] + p * sw[x] + p * w[fa[x]];
    w[x] = p;
    printf("%.5lf\n", sum1 - sum2);
  }
  return 0;
}
