#include <bits/stdc++.h>
using namespace std;
double ans, p[100010], prChildren[100010];
int n, q, par[100010];
vector<vector<int> > gr;
void dfs(int x) {
  for (auto i : gr[x]) {
    if (i == par[x]) {
      continue;
    }
    par[i] = x;
    dfs(i);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    p[i] = 1 - p[i];
  }
  gr.resize(n, vector<int>());
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  dfs(0);
  for (int i = 0; i < n; ++i) {
    for (auto x : gr[i]) {
      if (x == par[i]) {
        continue;
      }
      prChildren[i] += p[x];
    }
  }
  for (int i = 0; i < n; ++i) {
    ans += p[i] * (1 - prChildren[i]);
  }
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int x;
    double k;
    cin >> x >> k;
    k = 1 - k;
    if (!x) {
      ans -= p[x] * (1 - prChildren[x]);
      p[x] = k;
      ans += k * (1 - prChildren[x]);
    }
    ans -= p[x] * (1 - prChildren[x]);
    ans -= p[par[x]] * (1 - prChildren[par[x]]);
    prChildren[par[x]] -= p[x];
    p[x] = k;
    prChildren[par[x]] += k;
    ans += p[x] * (1 - prChildren[x]);
    ans += p[par[x]] * (1 - prChildren[par[x]]);
    cout << setprecision(5) << fixed << ans << '\n';
  }
}
