#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, fu = 0;
  char ch = getchar();
  for (; ch < 48 || ch > 57; ch = getchar()) fu |= (ch == '-');
  for (; ch > 47 && ch < 58; ch = getchar()) x = x * 10 + ch - '0';
  return fu ? -x : x;
}
int n, head[100005], eot, fa[100005];
struct edge {
  int t, nxt;
} e[200005];
void add(int u, int v) {
  e[++eot] = (edge){v, head[u]};
  head[u] = eot;
  e[++eot] = (edge){u, head[v]};
  head[v] = eot;
}
double p[100005], sump[100005], ans, P;
void dfs(int x) {
  ans += p[fa[x]] * (1.00 - p[x]);
  for (int i = head[x]; i; i = e[i].nxt) {
    if (e[i].t == fa[x]) continue;
    fa[e[i].t] = x, dfs(e[i].t), sump[x] += 1.00 - p[e[i].t];
  }
}
int main() {
  n = read(), p[0] = 1.00;
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (int i = 1, u, v; i < n; i++) u = read() + 1, v = read() + 1, add(u, v);
  dfs(1);
  for (int Q = read(), x; Q--; printf("%.5lf\n", ans)) {
    x = read() + 1, scanf("%lf", &P);
    ans -= p[x] * sump[x] + (1.00 - p[x]) * p[fa[x]],
        sump[fa[x]] -= 1.00 - p[x];
    p[x] = P;
    ans += p[x] * sump[x] + (1.00 - p[x]) * p[fa[x]],
        sump[fa[x]] += 1.00 - p[x];
  }
  return 0;
}
