#include <bits/stdc++.h>
using namespace std;
int n, from, to, num, head[100010], father[100010], q;
double p[100010], sum, g[100010], ans;
int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x;
}
struct xx {
  int next, to;
} way[200010];
void add(int from, int to) {
  way[++num].next = head[from];
  way[num].to = to;
  head[from] = num;
}
void dfs(int x, int fa) {
  father[x] = fa;
  for (int i = head[x]; i; i = way[i].next) {
    int y = way[i].to;
    if (y == fa) continue;
    dfs(y, x);
    g[x] += (1 - p[y]);
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (int i = 1; i < n; i++) {
    from = read() + 1;
    to = read() + 1;
    add(from, to);
    add(to, from);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    ans = ans + (g[i]) * (1 - p[i]) + p[i];
  }
  q = read();
  p[0] = 1;
  while (q--) {
    int x = read() + 1;
    double r;
    scanf("%lf", &r);
    ans -= p[x] + (g[x]) * (1 - p[x]);
    ans += r + (g[x]) * (1 - r);
    ans -= g[father[x]] * (1 - p[father[x]]);
    g[father[x]] = g[father[x]] - (1 - p[x]) + (1 - r);
    ans += g[father[x]] * (1 - p[father[x]]);
    printf("%lf\n", n - ans);
    p[x] = r;
  }
  return 0;
}
