#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
double f[N], zf[N];
int pos[N], fa[N];
struct edge {
  int v, next;
} e[N * 2];
int n, num = 0, q;
void add(int x, int y) {
  e[num] = (edge){y, pos[x]};
  pos[x] = num++;
}
void dfs(int x, int ff) {
  fa[x] = ff;
  zf[x] = 0;
  for (int i = pos[x]; ~i; i = e[i].next)
    if (e[i].v != ff) dfs(e[i].v, x), zf[x] += 1 - f[e[i].v];
}
int main() {
  memset(pos, -1, sizeof(pos));
  scanf("%d", &n);
  for (int i = 0; i <= n - 1; i++) scanf("%lf", &f[i]);
  f[n] = 1;
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  dfs(0, n);
  double ans = 0;
  for (int i = 0; i <= n - 1; i++) ans += (1 - f[i]) * f[fa[i]];
  int q;
  scanf("%d", &q);
  while (q--) {
    int a;
    double b;
    scanf("%d%lf", &a, &b);
    ans -= (1 - f[a]) * f[fa[a]];
    ans -= zf[a] * f[a];
    zf[fa[a]] -= 1 - f[a];
    f[a] = b;
    zf[fa[a]] += 1 - f[a];
    ans += (1 - f[a]) * f[fa[a]];
    ans += zf[a] * f[a];
    printf("%.5lf\n", ans);
  }
  return 0;
}
