#include <bits/stdc++.h>
using namespace std;
int n;
double p[100005], f[100005], resE, resV;
int pa[100005];
vector<int> a[100005];
void DFS(int u) {
  for (auto v : a[u]) {
    if (v == pa[u]) continue;
    f[u] += p[v];
    pa[v] = u;
    DFS(v);
  }
  resV += p[u];
  resE += p[u] * f[u];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]), p[i] = 1.0 - p[i];
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u++;
    v++;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  DFS(1);
  int numQuery;
  scanf("%d", &numQuery);
  while (numQuery--) {
    int u;
    double q;
    scanf("%d %lf", &u, &q);
    u++;
    q = 1.0 - q;
    resV -= p[u];
    resE -= p[u] * f[u];
    resV += q;
    resE += q * f[u];
    if (pa[u]) {
      int v = pa[u];
      resE -= p[v] * f[v];
      f[v] += q - p[u];
      resE += p[v] * f[v];
    }
    p[u] = q;
    printf("%0.4f\n", resV - resE);
  }
}
