#include <bits/stdc++.h>
const int N = 1e6 + 10;
struct edge {
  int next, to;
} e[N << 1];
int n, last[N], fa[N], m, cnt;
double v[N], t[N], ans;
void add(int a, int b) {
  cnt++;
  e[cnt].next = last[a], last[a] = cnt;
  e[cnt].to = b;
}
void dfs(int x, int f) {
  fa[x] = f;
  ans -= v[x];
  for (int i = last[x]; i; i = e[i].next) {
    if (e[i].to == f) continue;
    dfs(e[i].to, x);
    t[x] += 1.0 - v[e[i].to];
  }
  ans -= (1.0 - v[x]) * t[x];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lf", &v[i]);
  for (int i = 1; i < n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    a++, b++;
    add(a, b), add(b, a);
  }
  ans = n;
  dfs(1, 0);
  scanf("%d", &m);
  while (m--) {
    int a;
    double x;
    scanf("%d %lf", &a, &x);
    a++;
    ans += (1.0 - v[a]) * t[a];
    if (fa[a]) ans += (1.0 - v[fa[a]]) * t[fa[a]];
    if (fa[a]) t[fa[a]] -= 1.0 - v[a];
    ans += v[a];
    v[a] = x;
    ans -= v[a];
    if (fa[a]) t[fa[a]] += 1.0 - v[a];
    ans -= (1.0 - v[a]) * t[a];
    if (fa[a]) ans -= (1.0 - v[fa[a]]) * t[fa[a]];
    printf("%lf\n", ans);
  }
}
