#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
struct Front_star {
  int u, v, nxt;
} e[N << 1];
int cnt = 0;
int first[N];
void add(int u, int v) {
  ++cnt;
  e[cnt].u = u;
  e[cnt].v = v;
  e[cnt].nxt = first[u];
  first[u] = cnt;
}
int n;
double ans = 0;
int fa[N];
double F[N];
double sum[N];
void DFS(int u, int fat) {
  for (int i = first[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fat) continue;
    fa[v] = u;
    DFS(v, u);
    sum[u] += (1.0 - F[v]);
  }
}
int main() {
  scanf("%d", &n);
  F[0] = 1;
  for (int i = 1; i <= n; ++i) {
    scanf("%lf", &F[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, 1);
  for (int i = 1; i <= n; ++i) {
    ans += (1.0 - F[i]) * (F[fa[i]]);
  }
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int pos;
    double v;
    scanf("%d%lf", &pos, &v);
    ++pos;
    ans -= (1.0 - F[pos]) * (F[fa[pos]]);
    ans -= sum[pos] * F[pos];
    sum[fa[pos]] -= (1.0 - F[pos]);
    F[pos] = v;
    ans += sum[pos] * F[pos];
    ans += (1.0 - F[pos]) * (F[fa[pos]]);
    sum[fa[pos]] += (1.0 - F[pos]);
    printf("%6lf\n", ans);
  }
}
