#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, next;
} a[210000];
int len, last[110000];
void ins(int x, int y) {
  len++;
  a[len].x = x;
  a[len].y = y;
  a[len].next = last[x];
  last[x] = len;
}
int fa[110000];
double p[110000], f[110000];
void dfs(int x) {
  f[x] = 0;
  for (int k = last[x]; k; k = a[k].next) {
    int y = a[k].y;
    if (y != fa[x]) {
      fa[y] = x;
      dfs(y);
      f[x] += p[y];
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  p[0] = 0;
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]), p[i] = 1.0 - p[i];
  len = 0;
  memset(last, 0, sizeof(last));
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x++, y++;
    ins(x, y), ins(y, x);
  }
  fa[1] = 0;
  dfs(1);
  double V = 0, E = 0;
  for (int i = 1; i <= n; i++) V += p[i], E += p[i] * f[i];
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int x;
    double pp;
    scanf("%d%lf", &x, &pp);
    x++, pp = 1 - pp;
    V -= p[x];
    E -= p[x] * f[x];
    E -= p[fa[x]] * f[fa[x]];
    f[fa[x]] = f[fa[x]] - p[x];
    p[x] = pp;
    f[fa[x]] = f[fa[x]] + p[x];
    V += p[x];
    E += p[x] * f[x];
    E += p[fa[x]] * f[fa[x]];
    printf("%.5lf\n", V - E);
  }
  return 0;
}
