#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, m, u, v, tot, head[maxn], fa[maxn];
double p[maxn], ps[maxn], ans, vv;
struct node {
  int to, nxt;
} e[maxn << 1];
void add(int x, int y) {
  e[++tot] = {y, head[x]};
  head[x] = tot;
}
void dfs(int now, int f) {
  ps[now] = 0;
  ans -= 1.0 - p[now];
  fa[now] = f;
  for (int i = head[now]; ~i; i = e[i].nxt) {
    int to = e[i].to;
    if (to == f) continue;
    ps[now] += p[to];
    ans -= p[now] * p[to];
    dfs(to, now);
  }
}
int main() {
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]), p[i] = 1 - p[i];
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    u++, v++;
    add(u, v);
    add(v, u);
  }
  ans = n;
  dfs(1, 0);
  cin >> m;
  while (m--) {
    scanf("%d%lf", &u, &vv);
    u++;
    ans += p[fa[u]] * ps[fa[u]] + p[u] * ps[u] + 1.0 - p[u];
    ps[fa[u]] -= p[u];
    p[u] = 1.0 - vv;
    ps[fa[u]] += p[u];
    ans -= p[fa[u]] * ps[fa[u]] + p[u] * ps[u] + 1.0 - p[u];
    printf("%.5lf\n", ans);
  }
  return 0;
}
