#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, x, y, q, fa[N];
double p[N], sum[N], w, ans;
vector<int> G[N];
void dfs(int u, int pr) {
  ans -= p[u];
  for (auto v : G[u])
    if (v != pr) {
      fa[v] = u;
      dfs(v, u);
      ans -= (1 - p[u]) * (1 - p[v]);
      sum[u] += 1 - p[v];
    }
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%lf", &p[i]);
  p[0] = 1;
  for (int i = (1); i <= (n - 1); i++)
    scanf("%d%d", &x, &y), x++, y++, G[x].push_back(y), G[y].push_back(x);
  ans = n;
  dfs(1, 0);
  scanf("%d", &q);
  for (int i = (1); i <= (q); i++) {
    scanf("%d%lf", &x, &w);
    x++;
    ans += p[x] + (1 - p[x]) * sum[x] + (1 - p[fa[x]]) * (1 - p[x]);
    sum[fa[x]] -= 1 - p[x];
    p[x] = w;
    ans -= p[x] + (1 - p[x]) * sum[x] + (1 - p[fa[x]]) * (1 - p[x]);
    sum[fa[x]] += 1 - p[x];
    printf("%.10lf\n", ans);
  }
  return 0;
}
