#include <bits/stdc++.h>
using namespace std;
struct edges {
  int to, next;
} edge[202020];
int first[101010], now;
void adde(int x, int y) {
  now++;
  edge[now].to = y;
  edge[now].next = first[x];
  first[x] = now;
}
double v[101010], sum[101010];
int fa[101010];
void work(int p) {
  for (int e = first[p]; e; e = edge[e].next)
    if (edge[e].to != fa[p]) {
      fa[edge[e].to] = p;
      work(edge[e].to);
    }
}
int main() {
  int n, x, y, q;
  double nv, ans = 0.0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lf", &v[i]);
  memset(first, 0, sizeof(first));
  now = 0;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    adde(x, y);
    adde(y, x);
  }
  v[n] = 1.0;
  fa[0] = n;
  work(0);
  for (int i = 0; i < n; i++) {
    ans += (1.0 - v[i]) * v[fa[i]];
    sum[fa[i]] += 1.0 - v[i];
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%lf", &x, &nv);
    ans += sum[x] * (nv - v[x]);
    ans -= (nv - v[x]) * v[fa[x]];
    sum[fa[x]] -= nv - v[x];
    v[x] = nv;
    printf("%.5lf\n", ans);
  }
  return 0;
}
