#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
struct node {
  int v, nxt;
} edge[maxn << 1];
int first[maxn], tot = 0;
void add(int u, int v) {
  edge[++tot].v = v;
  edge[tot].nxt = first[u];
  first[u] = tot;
}
int n, m;
double dp[maxn], p[maxn], ans = 0;
int f[maxn];
void dfs(int u, int fa) {
  ans += (1.0 - p[u]) * p[fa];
  for (int i = first[u]; i; i = edge[i].nxt) {
    int v = edge[i].v;
    if (v == fa) continue;
    dfs(v, u);
    f[v] = u;
    dp[u] += 1.0 - p[v];
  }
}
int main() {
  scanf("%d", &n);
  p[0] = 1.0;
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x++, y++;
    add(x, y);
    add(y, x);
  }
  dfs(1, 0);
  scanf("%d", &m);
  while (m--) {
    int u;
    double pp;
    scanf("%d%lf", &u, &pp);
    u++;
    ans -= dp[u] * p[u] + (1.0 - p[u]) * p[f[u]];
    dp[f[u]] -= 1.0 - p[u];
    p[u] = pp;
    ans += dp[u] * p[u] + (1.0 - p[u]) * p[f[u]];
    dp[f[u]] += 1.0 - p[u];
    printf("%.5f\n", ans);
  }
  return 0;
}
