#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
double ans;
double p[maxn];
double sum[maxn];
int father[maxn];
vector<int> G[maxn];
void Init() {
  p[0] = 1;
  for (int i = 1; i <= n; ++i) G[i].clear(), sum[i] = 0;
}
void DFS(int u, int fa) {
  father[u] = fa;
  ans += p[fa] * (1 - p[u]);
  for (auto it : G[u])
    if (it != fa) {
      DFS(it, u);
      sum[u] += 1 - p[it];
    }
}
void RUN() {
  while (~scanf("%d", &n)) {
    Init();
    for (int i = 1; i <= n; ++i) scanf("%lf", p + i);
    for (int i = 1, u, v; i < n; ++i) {
      scanf("%d %d", &u, &v);
      ++u, ++v;
      G[u].push_back(v);
      G[v].push_back(u);
    }
    ans = 0;
    DFS(1, 0);
    int q;
    scanf("%d", &q);
    while (q--) {
      int x;
      double v;
      scanf("%d %lf", &x, &v);
      ++x;
      ans -= p[father[x]] * (1 - p[x]) + p[x] * sum[x];
      sum[father[x]] -= 1.0 - p[x];
      p[x] = v;
      ans += p[father[x]] * (1 - p[x]) + p[x] * sum[x];
      sum[father[x]] += 1.0 - p[x];
      printf("%.5f\n", ans);
    }
  }
}
int main() {
  RUN();
  return 0;
}
