#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long double ans = 0;
  vector<long double> p(n), sum(n, 0);
  vector<long long> par(n, -1);
  vector<vector<long long>> g(n);
  for (long long i = 0; i < n; ++i) cin >> p[i], p[i] = 1 - p[i], ans += p[i];
  for (long long i = 0; i < n - 1; ++i) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    ans -= p[u] * p[v];
  }
  function<void(long long, long long)> dfs = [&](long long u,
                                                 long long p) -> void {
    par[u] = p;
    for (auto v : g[u])
      if (v != p) dfs(v, u);
  };
  dfs(0, -1);
  for (long long i = 1; i < n; ++i) sum[par[i]] += p[i];
  cout << "\n";
  long long q;
  cin >> q;
  while (q--) {
    long long x;
    long double y;
    cin >> x >> y;
    y = 1 - y;
    if (x) {
      ans = ans + (y - p[x]) - (p[par[x]] + sum[x]) * (y - p[x]);
      sum[par[x]] += (y - p[x]);
    } else
      ans = ans + (y - p[x]) - sum[x] * (y - p[x]);
    p[x] = y;
    cout << ans << "\n";
  }
}
