#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int maxe = 2e5 + 5;
int nxt[maxe];
int head[maxn];
int to[maxe];
int cnt = 0;
double sum[maxn];
double p[maxn];
int fa[maxn];
void add(int u, int v) {
  cnt++;
  nxt[cnt] = head[u];
  head[u] = cnt;
  to[cnt] = v;
}
double ans = 0.0;
void dfs(int u, int ba) {
  ans += (1 - p[u]) * p[ba];
  fa[u] = ba;
  for (int i = head[u]; i != -1; i = nxt[i]) {
    int v = to[i];
    if (v != ba) {
      dfs(v, u);
      sum[u] += (1 - p[v]);
    }
  }
}
int main() {
  memset(head, -1, sizeof(head));
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  p[0] = 1;
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    add(u + 1, v + 1);
    add(v + 1, u + 1);
  }
  dfs(1, 0);
  int q;
  scanf("%d", &q);
  while (q--) {
    int u;
    double b;
    scanf("%d %lf", &u, &b);
    u++;
    ans -= sum[u] * p[u] + (1 - p[u]) * p[fa[u]];
    sum[fa[u]] -= 1 - p[u];
    p[u] = b;
    ans += sum[u] * p[u] + (1 - p[u]) * p[fa[u]];
    sum[fa[u]] += 1 - p[u];
    printf("%.5lf\n", ans);
  }
}
