#include <bits/stdc++.h>
using namespace std;
double v, e, t[200010], p[200010];
int par[200010];
vector<int> g[200010];
void dfs(int at, int pai) {
  par[at] = pai;
  for (int x : g[at])
    if (x != pai) dfs(x, at), t[at] += p[x];
  e += t[at] * p[at];
}
int main() {
  int n, i, q, x, a, b;
  double prob;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%lf", &p[i]), p[i] = (1. - p[i]), v += p[i];
  for (i = 0; i < n - 1; i++)
    scanf("%d%d", &a, &b), g[a].push_back(b), g[b].push_back(a);
  dfs(0, 0);
  scanf("%d", &q);
  while (q-- > 0) {
    scanf("%d%lf", &x, &prob), prob = (1. - prob);
    v += (-p[x] + prob);
    if (x > 0)
      e -= (p[par[x]] * t[par[x]]), t[par[x]] += (-p[x] + prob),
          e += (p[par[x]] * t[par[x]]);
    e -= p[x] * t[x], p[x] = prob, e += p[x] * t[x];
    printf("%.10lf\n", v - e);
  }
}
