#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x;
}
const int N = 1e5 + 10;
int n, fa[N];
double ans, pb[N], sum[N];
struct edge {
  int to, next;
} e[N << 1];
int head[N], tot;
inline void add(int u, int v) {
  e[++tot] = (edge){v, head[u]};
  head[u] = tot;
}
void dfs(int x, int f) {
  fa[x] = f;
  ans += pb[fa[x]] * (1 - pb[x]);
  for (int i = head[x]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == f) continue;
    dfs(v, x);
    sum[x] += 1 - pb[v];
  }
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 1; i <= n; ++i) scanf("%lf", &pb[i]);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    ++u;
    ++v;
    add(u, v);
    add(v, u);
  }
  pb[0] = 1;
  dfs(1, 0);
  int Q;
  scanf("%d", &Q);
  int x;
  double cg;
  while (Q--) {
    scanf("%d%lf", &x, &cg);
    ++x;
    ans += (pb[x] - cg) * pb[fa[x]];
    ans += (cg - pb[x]) * sum[x];
    sum[fa[x]] -= cg - pb[x];
    pb[x] = cg;
    printf("%.6lf\n", ans);
  }
}
