#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int t, next;
  Edge() {}
  Edge(int a, int b) : t(a), next(b) {}
};
Edge e[200005];
int head[100005];
double num[100005], sum[100005], ans;
int fa[100005];
void dfs(int x) {
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].t != fa[x]) {
      int u = e[i].t;
      fa[u] = x;
      sum[x] += num[u];
      ans -= num[x] * num[u];
      dfs(u);
    }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &num[i]);
    num[i] = 1.0 - num[i];
    ans += num[i];
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x++;
    y++;
    e[2 * i - 1] = Edge(y, head[x]);
    head[x] = 2 * i - 1;
    e[2 * i] = Edge(x, head[y]);
    head[y] = 2 * i;
  }
  dfs(1);
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x;
    double y;
    scanf("%d%lf", &x, &y);
    x++;
    y = 1.0 - y;
    ans += y - num[x];
    ans -= (y - num[x]) * (sum[x] + num[fa[x]]);
    if (fa[x]) sum[fa[x]] += y - num[x];
    num[x] = y;
    printf("%.10f\n", ans);
  }
  return 0;
}
