#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int ln[maxn], n, m, kl, head[maxn], x, fa[maxn], Q;
double f[maxn], sum[maxn], ans, y;
struct line {
  int fr, to, next;
} q[maxn * 2];
void dfs(int x, int fat) {
  fa[x] = fat;
  ans += f[fa[x]] * (1 - f[x]);
  for (int p = head[x]; int v = q[p].to; p = q[p].next) {
    if (v == fat) continue;
    sum[x] += (1 - f[v]);
    dfs(v, x);
  }
}
void pushline(int f, int t) {
  q[++kl].to = t;
  q[kl].fr = f;
  q[kl].next = head[f];
  head[f] = kl;
}
int main() {
  cin >> n;
  f[0] = 1;
  for (int i = 1; i <= n; i++) scanf("%lf", &f[i]);
  for (int i = 1; i < n; i++)
    scanf("%d%lf", &x, &y), pushline(x + 1, y + 1), pushline(y + 1, x + 1);
  dfs(1, 0);
  cin >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%lf", &x, &y);
    x++;
    ans = ans - f[fa[x]] * (1 - f[x]) + f[fa[x]] * (1 - y);
    ans = ans - sum[x] * f[x] + sum[x] * y;
    sum[fa[x]] = sum[fa[x]] - (1 - f[x]) + (1 - y);
    f[x] = y;
    printf("%.5lf\n", ans);
  }
}
