#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
double p[maxn], s[maxn], ans;
vector<int> V[maxn];
int fa[maxn];
void dfs(int u) {
  ans += p[fa[u]] * (1.0 - p[u]);
  for (int i = 0; i < V[u].size(); i++) {
    if (V[u][i] == fa[u]) continue;
    fa[V[u][i]] = u;
    dfs(V[u][i]);
    s[u] += 1.0 - p[V[u][i]];
  }
}
int main() {
  int n, u, v;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    u++, v++;
    V[u].push_back(v);
    V[v].push_back(u);
  }
  fa[1] = 0;
  p[0] = 1.0;
  dfs(1);
  int Q, x;
  double y;
  cin >> Q;
  while (Q--) {
    scanf("%d%lf", &x, &y);
    x++;
    ans -= p[fa[x]] * (1.0 - p[x]);
    ans -= p[x] * s[x];
    s[fa[x]] -= (1.0 - p[x]);
    p[x] = y;
    ans += p[fa[x]] * (1.0 - p[x]);
    ans += p[x] * s[x];
    s[fa[x]] += (1.0 - p[x]);
    printf("%.5lf\n", ans);
  }
  return 0;
}
