#include <bits/stdc++.h>
using namespace std;
const int imx = 100005;
double p[imx] = {1};
double sum[imx];
double ans = 0;
int head[imx];
int n, m;
int a;
double b;
int fa[imx];
struct edge {
  int to, nxt;
} e[imx * 2];
int cnt = 0;
void add(int u, int v) {
  e[++cnt].to = v;
  e[cnt].nxt = head[u];
  head[u] = cnt;
}
void dfs(int u) {
  ans += p[fa[u]] * (1 - p[u]);
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa[u]) continue;
    fa[v] = u;
    dfs(v);
    sum[u] += (1 - p[v]);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u++, v++;
    add(u, v);
    add(v, u);
  }
  dfs(1);
  cin >> m;
  while (m--) {
    scanf("%d%lf", &a, &b);
    a++;
    ans += p[fa[a]] * (1 - b) - p[fa[a]] * (1 - p[a]);
    ans += sum[a] * b - sum[a] * p[a];
    sum[fa[a]] += p[a] - b;
    p[a] = b;
    printf("%.5lf\n", ans);
  }
}
