#include <bits/stdc++.h>
constexpr int MAX_N = 100100;
using namespace std;
using ld = long double;
int n, q;
ld p[MAX_N];
vector<int> adj[MAX_N];
int par[MAX_N];
ld sum_child_p[MAX_N];
ld e_nodes, e_edges;
void dfs(int u, int pa) {
  par[u] = pa;
  for (int v : adj[u]) {
    if (v == pa) continue;
    sum_child_p[u] += p[v];
    dfs(v, u);
  }
}
void update(int u, ld new_p) {
  e_nodes -= p[u];
  e_nodes += new_p;
  e_edges -= p[u] * sum_child_p[u];
  e_edges += new_p * sum_child_p[u];
  if (par[u] != -1) {
    e_edges -= p[u] * p[par[u]];
    e_edges += new_p * p[par[u]];
  }
  if (par[u] != -1) {
    sum_child_p[par[u]] -= p[u];
    sum_child_p[par[u]] += new_p;
  }
  p[u] = new_p;
}
int main() {
  memset(par, -1, sizeof(par));
  scanf(" %d", &n);
  for (int i = 0; i < n; ++i) {
    scanf(" %Lf", &p[i]);
    p[i] = 1 - p[i];
    e_nodes += p[i];
  }
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf(" %d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
    e_edges += p[u] * p[v];
  }
  dfs(0, -1);
  scanf(" %d", &q);
  for (int i = 0; i < q; ++i) {
    int u;
    ld new_p;
    scanf(" %d %Lf", &u, &new_p);
    update(u, 1 - new_p);
    printf("%0.10Lf\n", e_nodes - e_edges);
  }
  return 0;
}
