#include <bits/stdc++.h>
std::mt19937 rng(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
const int ms = 100100;
std::vector<int> edges[ms];
int up[ms];
void pre(int on, int par = -1) {
  up[on] = par;
  for (auto to : edges[on]) {
    if (to == par) continue;
    pre(to, on);
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int n;
  std::cin >> n;
  std::cout << std::fixed << std::setprecision(12);
  std::vector<double> p(n);
  for (int i = 0; i < n; i++) {
    std::cin >> p[i];
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    std::cin >> u >> v;
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  std::vector<double> down(n, 0);
  pre(0);
  for (int i = 1; i < n; i++) {
    down[up[i]] += 1 - p[i];
  }
  double ans = 0;
  for (int i = 1; i < n; i++) {
    ans += (1 - p[i]) * p[up[i]];
  }
  ans += 1 - p[0];
  int q;
  std::cin >> q;
  while (q--) {
    int x;
    double newP;
    std::cin >> x >> newP;
    ans += down[x] * (newP - p[x]);
    if (x > 0) {
      double hmm = p[up[x]];
      ans -= hmm * (newP - p[x]);
      down[up[x]] -= newP - p[x];
    } else {
      ans -= newP - p[x];
    }
    p[x] = newP;
    std::cout << ans << '\n';
  }
}
