#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
vector<int> G[100005];
int f[100005];
int p[100005];
long long sV, sE;
void dfs(int u) {
  for (auto v : G[u]) {
    if (v == p[u]) continue;
    p[v] = u;
    dfs(v);
    f[u] += a[v];
  }
}
void up(int x, int nv) {
  sV -= a[x];
  sE -= a[x] * f[x];
  if (x) {
    sE -= a[p[x]] * f[p[x]];
    f[p[x]] -= a[x];
  }
  a[x] = nv;
  sV += a[x];
  if (x) {
    f[p[x]] += a[x];
    sE += a[p[x]] * f[p[x]];
  }
  sE += a[x] * f[x];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    double x;
    scanf("%lf", &x);
    a[i] = 100 - (int)(x * 100 + 0.5);
  }
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  p[0] = -1;
  dfs(0);
  for (int i = 0; i < n; i++) {
    sV += a[i];
    sE += a[i] * f[i];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int u;
    double x;
    scanf("%d%lf", &u, &x);
    up(u, 100 - (int)(x * 100 + 0.5));
    double ans = (sV * 100 - sE) / 10000.0;
    printf("%.4f\n", ans);
  }
}
