#include <bits/stdc++.h>
const int maxn = 100100;
struct T {
  int to, nxt;
} way[maxn << 1];
int h[maxn], num;
inline void adde(int x, int y) {
  way[++num] = {y, h[x]}, h[x] = num;
  way[++num] = {x, h[y]}, h[y] = num;
}
int fa[maxn], vis[maxn];
double sum[maxn], v[maxn];
inline void dfs(int a) {
  vis[a] = 1;
  for (int i = h[a]; i; i = way[i].nxt)
    if (!vis[way[i].to]) {
      dfs(way[i].to);
      fa[way[i].to] = a;
      sum[a] += v[way[i].to];
    }
}
double ans = 0, Sm = 0;
int main() {
  int n, q;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lf", v + i), Sm += v[i] = 1 - v[i];
  for (int i = 1, x, y; i < n; ++i)
    scanf("%d%d", &x, &y), adde(x + 1, y + 1), ans += v[x + 1] * v[y + 1];
  dfs(1);
  scanf("%d", &q);
  while (q--) {
    int x;
    double p;
    scanf("%d%lf", &x, &p), p = 1 - p, ++x;
    Sm -= v[x], Sm += p;
    ans -= (v[fa[x]] + sum[x]) * v[x];
    if (x != 1) sum[fa[x]] -= v[x], sum[fa[x]] += p;
    v[x] = p;
    ans += (v[fa[x]] + sum[x]) * v[x];
    printf("%.6lf\n", Sm - ans);
  }
}
