#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, q, fa[N];
double p[N], sum[N], ans;
vector<int> son[N];
void dfs(int x, int f) {
  fa[x] = f;
  for (int i = 0; i < son[x].size(); ++i) {
    int y = son[x][i];
    if (y == f) continue;
    dfs(y, x);
    sum[x] += 1 - p[y];
    ans += p[x] * (1 - p[y]);
  }
}
int main() {
  scanf("%d", &n);
  p[0] = 1;
  for (int i = 1; i <= n; ++i) scanf("%lf", p + i);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    ++u, ++v;
    son[u].push_back(v);
    son[v].push_back(u);
  }
  ans = 1 - p[1];
  dfs(1, 0);
  scanf("%d", &q);
  while (q--) {
    int k;
    double p1;
    scanf("%d%lf", &k, &p1);
    ++k;
    sum[fa[k]] -= p1 - p[k];
    ans += sum[k] * (p1 - p[k]) - (p1 - p[k]) * p[fa[k]];
    p[k] = p1;
    printf("%.5lf\n", ans);
  }
  return 0;
}
