#include <bits/stdc++.h>
using namespace std;
int n, m, fa[100005];
double ans, p[100005], sum[100005];
vector<int> g[100005];
void dfs(int x, int pa) {
  for (int i = 0; i < g[x].size(); i++)
    if (g[x][i] != pa) {
      int v = g[x][i];
      fa[v] = x;
      dfs(v, x);
      sum[x] += 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, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    u++;
    v++;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) ans += p[fa[i]] * (1 - p[i]);
  scanf("%d", &m);
  while (m--) {
    int a;
    double c;
    scanf("%d%lf", &a, &c);
    a++;
    ans -= p[fa[a]] * (1 - p[a]);
    ans -= sum[a] * p[a];
    sum[fa[a]] -= 1 - p[a];
    p[a] = c;
    ans += p[fa[a]] * (1 - p[a]);
    ans += sum[a] * p[a];
    sum[fa[a]] += 1 - p[a];
    printf("%.8f\n", ans);
  }
  return 0;
}
