#include <bits/stdc++.h>
using namespace std;
int n, q;
int fa[100005];
double a[100005], sum[100005], ans;
vector<int> g[100005];
void dfs(int now, int f) {
  fa[now] = f;
  for (int i = 0; i < g[now].size(); i++) {
    int v = g[now][i];
    if (v == f) continue;
    dfs(v, now);
    sum[now] += (1 - a[v]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &a[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x++, y++;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  a[0] = 1;
  sum[0] = 1 - a[1];
  dfs(1, 0);
  for (int i = 0; i <= n; i++) ans += a[i] * sum[i];
  scanf("%d", &q);
  while (q--) {
    int x;
    double y;
    scanf("%d%lf", &x, &y);
    x++;
    ans = ans - sum[x] * a[x] + sum[x] * y;
    ans = ans - a[fa[x]] * (1 - a[x]) + a[fa[x]] * (1 - y);
    sum[fa[x]] = sum[fa[x]] - (1 - a[x]) + (1 - y);
    a[x] = y;
    printf("%lf\n", ans);
  }
}
