#include <bits/stdc++.h>
using namespace std;
struct node {
  int next, to;
} e[1000010];
int head[1000010], num;
void add(int fr, int to) {
  e[++num].next = head[fr];
  e[num].to = to;
  head[fr] = num;
}
int n, m, a, fa[1000010];
double ans, sum[1000010], p[1000010] = {1}, b;
void dfs(int fr) {
  ans += p[fa[fr]] * (1 - p[fr]);
  for (int i = head[fr]; i; i = e[i].next) {
    int ca = e[i].to;
    if (ca == fa[fr]) continue;
    fa[ca] = fr;
    dfs(ca);
    sum[fr] += (1 - p[ca]);
  }
}
int main(int argc, char const *argv[]) {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (int i = 1; i < n; i++) {
    scanf("%d%lf", &a, &b);
    a++, b++;
    add(a, b);
    add(b, a);
  }
  dfs(1);
  cin >> m;
  while (m--) {
    scanf("%d%lf", &a, &b);
    a++;
    ans += p[fa[a]] * (1 - b) - p[fa[a]] * (1 - p[a]);
    ans += sum[a] * b - sum[a] * p[a];
    sum[fa[a]] += p[a] - b;
    p[a] = b;
    printf("%.5lf\n", ans);
  }
  return 0;
}
