#include <bits/stdc++.h>
using namespace std;
int n, Q, fa[100010], k, la[100010], ff[100010 * 2];
double s[100010], sum[100010], ans;
struct node {
  int a, b;
} e[100010 * 2];
void add(int a, int b) {
  e[++k] = (node){a, b};
  ff[k] = la[a];
  la[a] = k;
  e[++k] = (node){b, a};
  ff[k] = la[b];
  la[b] = k;
}
void dfs(int x) {
  ans += (1 - s[x]) * s[fa[x]];
  sum[fa[x]] += 1 - s[x];
  for (int a = la[x]; a; a = ff[a])
    if (e[a].b != fa[x]) fa[e[a].b] = x, dfs(e[a].b);
}
int main() {
  int a, b, x;
  double y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &s[i]);
  for (int i = 1; i < n; i++) scanf("%d%d", &a, &b), add(a + 1, b + 1);
  s[0] = 1;
  dfs(1);
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d%lf", &x, &y);
    x++;
    ans -= (1 - s[x]) * s[fa[x]];
    ans -= s[x] * sum[x];
    sum[fa[x]] -= 1 - s[x];
    s[x] = y;
    sum[fa[x]] += 1 - s[x];
    ans += (1 - s[x]) * s[fa[x]];
    ans += s[x] * sum[x];
    printf("%lf\n", ans);
  }
  return 0;
}
