#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 15;
int n, q, ph[maxn];
double p[maxn], f[maxn], ans;
vector<int> g[maxn];
void dfs(int u) {
  for (auto v : g[u])
    if (v != ph[u]) {
      ph[v] = u;
      f[u] += p[v];
      dfs(v);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &p[i]);
    p[i] = 1 - p[i];
  }
  for (int i = 1; i < n; i++) {
    int v, u;
    scanf("%d%d", &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]);
  scanf("%d", &q);
  while (q--) {
    int u;
    double c;
    scanf("%d%lf", &u, &c), u++;
    ans -= (p[u] - p[u] * f[u] + p[ph[u]] - p[ph[u]] * f[ph[u]]);
    f[ph[u]] -= p[u];
    p[u] = 1 - c;
    f[ph[u]] += p[u];
    ans += (p[u] - p[u] * f[u] + p[ph[u]] - p[ph[u]] * f[ph[u]]);
    cout << setprecision(7) << ans << endl;
  }
  return 0;
}
