#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4;
inline int Get() {
  register char c = getchar();
  register int t = 0, f = 0;
  while (c < '0' || c > '9') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') t = (t << 3) + (t << 1) + c - '0', c = getchar();
  return f ? -t : t;
}
double v[N], sum[N];
double ans;
int fa[N];
int n, m;
vector<int> ve[N];
void Dfs(int u) {
  ans -= 1 - v[u];
  for (int i = 0, lim = ve[u].size(); i < lim; ++i) {
    int vv = ve[u][i];
    if (vv == fa[u]) continue;
    fa[vv] = u;
    ans -= v[u] * v[vv];
    sum[u] += v[vv];
    Dfs(vv);
  }
}
int main() {
  int x, y;
  n = Get();
  for (int i = (1); i <= (n); ++i) scanf("%lf", &v[i]), v[i] = 1 - v[i];
  for (int i = (1); i <= (n - 1); ++i) {
    x = Get() + 1, y = Get() + 1;
    ve[x].push_back(y);
    ve[y].push_back(x);
  }
  ans = n;
  Dfs(1);
  m = Get();
  while (m--) {
    double t;
    x = Get() + 1;
    scanf("%lf", &t);
    ans += 1 - v[x] + v[fa[x]] * sum[fa[x]] + v[x] * sum[x];
    sum[fa[x]] -= v[x];
    v[x] = 1 - t;
    sum[fa[x]] += v[x];
    ans -= 1 - v[x] + v[fa[x]] * sum[fa[x]] + v[x] * sum[x];
    printf("%.5lf\n", ans);
  }
  return 0;
}
