#include <bits/stdc++.h>
using namespace std;
const int maxn = 205000;
struct edge {
  int x, y;
} e[maxn * 2];
double a[maxn], f[maxn];
int n, q;
int fa[maxn];
double ans;
vector<int> g[maxn];
void dfs(int u) {
  for (auto v : g[u]) {
    if (v == fa[u]) continue;
    fa[v] = u;
    f[u] += a[v];
    dfs(v);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &a[i]), a[i] = 1.0 - a[i];
  for (int i = 2; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x++;
    y++;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1);
  for (int i = 1; i <= n; i++) ans += a[i] * (1.0 - f[i]);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int x;
    double y;
    scanf("%d%lf", &x, &y);
    x++;
    y = 1.0 - y;
    ans -= a[x] * (1.0 - f[x]);
    ans -= a[fa[x]] * (1.0 - f[fa[x]]);
    f[fa[x]] += y - a[x];
    a[x] = y;
    ans += a[x] * (1.0 - f[x]);
    ans += a[fa[x]] * (1.0 - f[fa[x]]);
    printf("%.10lf\n", ans);
  }
  return 0;
}
