#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
int n, q, fa[N];
vector<int> g[N];
double p[N], s[N], ans;
inline void dfs(int x, int f) {
  ans += p[f] * (1 - p[x]);
  for (auto v : g[x])
    if (v != f) fa[v] = x, s[x] += (1 - p[v]), dfs(v, x);
}
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 x, y;
    scanf("%d%d", &x, &y);
    ++x;
    ++y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 0);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int x;
    double t;
    scanf("%d%lf", &x, &t);
    ++x;
    ans -= p[x] * s[x];
    ans -= p[fa[x]] * (1 - p[x]);
    ans += t * s[x];
    ans += p[fa[x]] * (1 - t);
    s[fa[x]] -= (1 - p[x]);
    s[fa[x]] += (1 - t);
    p[x] = t;
    printf("%.5f\n", ans);
  }
}
