#include <bits/stdc++.h>
using namespace std;
int n, q;
float p[100005];
vector<int> g[100005];
float sumc[100005], cont[100005];
int par[100005];
void dfs(int st, int pr) {
  par[st] = pr;
  for (int v : g[st])
    if (v != pr) {
      dfs(v, st);
      sumc[st] += (1.0 - p[v]);
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(8);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> p[i];
  for (int i = 1; i <= n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    u++;
    v++;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 1);
  float ans = 1.0 - p[1];
  for (int st = 1; st <= n; ++st) {
    ans += p[st] * sumc[st];
    cont[st] = p[st] * sumc[st];
  }
  cin >> q;
  while (q--) {
    int u;
    float pp;
    cin >> u >> pp;
    u++;
    float temp = p[u];
    p[u] = pp;
    int st = u;
    ans -= cont[st];
    cont[st] = sumc[st] * p[st];
    ans += cont[st];
    if (st == 1) {
      ans -= (1.0 - temp);
      ans += (1.0 - p[1]);
    } else {
      int pr = par[st];
      ans -= cont[pr];
      sumc[pr] -= (1.0 - temp);
      sumc[pr] += (1.0 - p[st]);
      cont[pr] = sumc[pr] * p[pr];
      ans += cont[pr];
    }
    cout << ans << '\n';
  }
}
