#include <bits/stdc++.h>
const int INF = std::numeric_limits<int>::max() / 2;
const long long INFLL = std::numeric_limits<long long>::max() / 2;
const int MAX_N = 1e5;
int n, q, par[MAX_N];
std::vector<int> adj[MAX_N];
double prb[MAX_N], sub[MAX_N];
void dfs(int i) {
  for (int j : adj[i])
    if (j != par[i]) {
      sub[i] += 1.0 - prb[j];
      par[j] = i;
      dfs(j);
    }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> prb[i];
  for (int i = 1; i < n; ++i) {
    int u, v;
    std::cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  par[0] = -1;
  dfs(0);
  double ans = (1.0 - prb[0]);
  for (int i = 0; i < n; ++i) ans += prb[i] * sub[i];
  std::cin >> q;
  while (q--) {
    int i;
    double p;
    std::cin >> i >> p;
    ans += (prb[i] - p) * (par[i] == -1 ? 1.0 : prb[par[i]]);
    ans += (p - prb[i]) * sub[i];
    if (par[i] != -1) sub[par[i]] += prb[i] - p;
    prb[i] = p;
    std::cout << ans << '\n';
  }
  return 0;
}
