#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int head[N], to[N << 1], nxt[N << 1], cnt;
inline void addedge(int x, int y) {
  to[++cnt] = y, nxt[cnt] = head[x], head[x] = cnt;
  to[++cnt] = x, nxt[cnt] = head[y], head[y] = cnt;
}
int fa[N];
double p[N], s[N];
inline void dfs(int x) {
  for (int i = head[x]; i; i = nxt[i]) {
    if (to[i] == fa[x]) continue;
    fa[to[i]] = x;
    dfs(to[i]);
    s[x] += 1 - p[to[i]];
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    addedge(x + 1, y + 1);
  }
  dfs(1);
  p[0] = 1;
  double ans = 0;
  for (int i = 1; i <= n; i++) ans += (1 - p[i]) * p[fa[i]];
  int q;
  scanf("%d", &q);
  while (q--) {
    int x;
    double y;
    scanf("%d%lf", &x, &y);
    x++;
    ans += (p[x] - y) * (p[fa[x]] - s[x]);
    if (fa[x]) s[fa[x]] += p[x] - y;
    p[x] = y;
    printf("%.4lf\n", ans);
  }
  return 0;
}
