#include <bits/stdc++.h>
using namespace std;
long double p[(int)1e5 + 1];
vector<int> adj[(int)1e5 + 1];
int parent[(int)1e5 + 1];
long double dp[(int)1e5 + 1];
void dfs(const int u) {
  for (const int &v : adj[u])
    if (v != parent[u]) {
      parent[v] = u;
      dp[u] += 1 - p[v];
      dfs(v);
    }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> p[i];
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  p[n] = 1;
  adj[n].push_back(0);
  adj[0].push_back(n);
  parent[n] = -1;
  dfs(n);
  long double ans = 0;
  for (int i = 0; i < n; ++i) ans += (1 - p[i]) * p[parent[i]];
  int Q;
  cin >> Q;
  while (Q--) {
    int i;
    long double x;
    cin >> i >> x;
    ans -= (1 - p[i]) * p[parent[i]];
    ans -= dp[i] * p[i];
    p[i] = x;
    ans += (1 - p[i]) * p[parent[i]];
    ans += dp[i] * p[i];
    cout << ans << '\n';
  }
  return 0;
}
