#include <bits/stdc++.h>
using namespace std;
double P[100005], sum[100005], ans = 0;
int n, q, first[100005], cnt = 0, fa[100005];
struct edge {
  int v, next;
} e[100005 << 1];
inline void add(int u, int v) {
  e[++cnt].v = v, e[cnt].next = first[u], first[u] = cnt;
}
inline void dfs(int p) {
  ans += P[fa[p]] * (1 - P[p]);
  for (int i = first[p]; i; i = e[i].next) {
    int v = e[i].v;
    if (v == fa[p]) continue;
    fa[v] = p, dfs(v), sum[p] += 1 - P[v];
  }
}
inline int read() {
  int ans = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) ans = (ans << 3) + (ans << 1) + (ch ^ 48), ch = getchar();
  return ans;
}
int main() {
  n = read(), P[0] = 1;
  for (int i = 1; i <= n; ++i) scanf("%lf", &P[i]);
  for (int i = 1; i < n; ++i) {
    int u = read() + 1, v = read() + 1;
    add(u, v), add(v, u);
  }
  dfs(1), q = read();
  while (q--) {
    int a = read() + 1;
    double b;
    scanf("%lf", &b);
    ans -= P[a] * sum[a] + P[fa[a]] * (1 - P[a]), sum[fa[a]] -= 1 - P[a];
    P[a] = b;
    ans += P[a] * sum[a] + P[fa[a]] * (1 - P[a]), sum[fa[a]] += 1 - P[a];
    printf("%.5lf\n", ans);
  }
  return 0;
}
