#include <bits/stdc++.h>
using namespace std;
int n, q, fa[100050];
long double p[100050], sum[100050], ans;
vector<int> adj[100050];
void dfs(int u) {
  ans += (1.0 - p[u]) * p[fa[u]];
  for (register int i = 0; i < adj[u].size(); ++i)
    if (adj[u][i] != fa[u])
      fa[adj[u][i]] = u, sum[u] += 1.0 - p[adj[u][i]], dfs(adj[u][i]);
}
int main() {
  int u, v;
  double w;
  scanf("%d", &n);
  p[0] = 1;
  for (register int i = 1; i <= n; ++i) scanf("%lf", &w), p[i] = w;
  for (register int i = 1; i < n; ++i)
    scanf("%d%d", &u, &v), ++u, ++v, adj[u].push_back(v), adj[v].push_back(u);
  dfs(1);
  scanf("%d", &q);
  while (q--) {
    scanf("%d%lf", &u, &w);
    ++u;
    ans -= (1.0 - p[u]) * p[fa[u]];
    ans -= sum[u] * p[u];
    sum[fa[u]] -= 1.0 - p[u];
    p[u] = w;
    ans += (1.0 - p[u]) * p[fa[u]];
    ans += sum[u] * p[u];
    sum[fa[u]] += 1.0 - p[u];
    printf("%.6lf\n", double(ans));
  }
  return 0;
}
