#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
const int N = 1e5 + 10;
VI adj[N];
using ld = double;
int par[N];
ld prob[N], ch[N];
ld ans = 0;
void dfs(int u, int p) {
  par[u] = p;
  ans += (1 - prob[u]) * prob[p];
  for (int v : adj[u]) {
    if (v == p) continue;
    ch[u] += 1 - prob[v];
    dfs(v, u);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  prob[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> prob[i];
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u++, v++;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0);
  int q;
  cin >> q;
  cout << setprecision(10) << fixed;
  while (q--) {
    int u;
    ld pp;
    cin >> u >> pp;
    u++;
    ans -= (1 - prob[u]) * prob[par[u]];
    ans -= prob[u] * ch[u];
    ch[par[u]] -= (1 - prob[u]);
    prob[u] = pp;
    ch[par[u]] += (1 - prob[u]);
    ans += prob[u] * ch[u];
    ans += (1 - prob[u]) * prob[par[u]];
    cout << ans << '\n';
  }
  return 0;
}
