#include <bits/stdc++.h>
using namespace std;
int n, q;
vector<int> adj[100010];
double pr[100010];
double res;
int sn[100010];
double snm[100010];
int fa[100010];
void dfs(int i) {
  res += (1 - pr[i]) * pr[fa[i]];
  for (int j = adj[i].size() - 1; ~j; --j) {
    if (adj[i][j] != fa[i])
      fa[adj[i][j]] = i, dfs(adj[i][j]), ++sn[i], snm[i] += pr[adj[i][j]];
  }
}
int main(void) {
  fa[1] = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lf", &pr[i]);
    snm[i] = 0;
  }
  pr[0] = 1;
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    ++u;
    ++v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1);
  scanf("%d", &q);
  while (q--) {
    int x;
    double nw;
    scanf("%d%lf", &x, &nw);
    ++x;
    res -= (1 - pr[x]) * pr[fa[x]];
    res -= (sn[x] - snm[x]) * pr[x];
    pr[x] = nw;
    res += (1 - pr[x]) * pr[fa[x]];
    res += (sn[x] - snm[x]) * pr[x];
    printf("%.8f\n", res);
  }
  return 0;
}
