#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
int n, q, fa[MAX];
double p[MAX], f[MAX], ans;
vector<int> g[MAX];
void dfs(int u) {
  for (auto v : g[u])
    if (v != fa[u]) {
      fa[v] = u;
      f[u] += p[v];
      dfs(v);
    }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i], p[i] = 1 - p[i];
  for (int i = 1, v, u; i < n; i++)
    cin >> v >> u, v++, u++, g[v].push_back(u), g[u].push_back(v);
  dfs(1);
  for (int i = 1; i <= n; i++) ans += (p[i] - p[i] * f[i]);
  cin >> q;
  while (q--) {
    int u;
    double c;
    cin >> u >> c, u++;
    ans -= (p[u] - p[u] * f[u] + p[fa[u]] - p[fa[u]] * f[fa[u]]);
    f[fa[u]] -= p[u];
    p[u] = 1.0 - c;
    f[fa[u]] += p[u];
    ans += (p[u] - p[u] * f[u] + p[fa[u]] - p[fa[u]] * f[fa[u]]);
    cout << setprecision(7) << ans << "\n";
  }
  return 0;
}
