#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = (int)1e5 + 7;
const int infint = (int)1e9;
const long long inf = (long long)1e18;
int n;
vector<int> G[MAXN];
double p[MAXN], sig[MAXN], ans = 0;
int ped[MAXN], u, v;
void dfs(int u, int par) {
  ped[u] = par;
  if (par != -1)
    ans += (1 - p[u]) * p[par];
  else
    ans += (1 - p[u]);
  for (auto v : G[u])
    if (v != par) {
      sig[u] += (1 - p[v]);
      dfs(v, u);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lf", &p[i]);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(0, -1);
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int v;
    double pro;
    scanf("%d %lf", &v, &pro);
    if (ped[v] != -1) sig[ped[v]] -= (1 - p[v]);
    sig[ped[v]] += (1 - pro);
    ans -= p[v] * sig[v];
    ans += pro * sig[v];
    if (ped[v] != -1)
      ans -= (1 - p[v]) * p[ped[v]];
    else
      ans -= (1 - p[v]);
    if (ped[v] != -1)
      ans += (1 - pro) * p[ped[v]];
    else
      ans += (1 - pro);
    p[v] = pro;
    printf("%.4lf\n", ans);
  }
}
