#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
const int mod = 1e9 + 7;
const int MX = 2e5 + 5;
vector<int> E[MX];
int f[MX];
double p[MX], t[MX], ans;
void dfs(int u, int pre) {
  f[u] = pre;
  ans -= p[u];
  for (auto v : E[u]) {
    if (v == pre) continue;
    t[u] += 1 - p[v];
    dfs(v, u);
  }
  ans -= t[u] * (1 - p[u]);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < (n + 1); ++i) scanf("%lf", &p[i]);
  for (int i = 1; i < (n); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    u++, v++;
    E[u].push_back(v);
    E[v].push_back(u);
  }
  ans = n;
  dfs(1, 0);
  int q;
  cin >> q;
  while (q--) {
    int u;
    double r;
    scanf("%d%lf", &u, &r);
    u++;
    ans += (1 - p[u]) * t[u] + p[u];
    if (f[u]) ans += (1 - p[u]) * (1 - p[f[u]]);
    t[f[u]] += (1 - r) - (1 - p[u]);
    ans -= (1 - r) * t[u] + r;
    if (f[u]) ans -= (1 - r) * (1 - p[f[u]]);
    p[u] = r;
    printf("%.6f\n", ans);
  }
  return 0;
}
