#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n;
int fa[maxn];
double ans = 0;
double v[maxn];
double vson[maxn];
vector<int> q[maxn];
void dfs(int x, int pre) {
  ans -= 1.0 - v[x];
  fa[x] = pre, vson[x] = 0;
  for (int y : q[x])
    if (y != pre) {
      ans -= v[x] * v[y];
      vson[x] += v[y];
      dfs(y, x);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) q[i].clear();
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &v[i]);
    v[i] = 1.0 - v[i];
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x++;
    y++;
    q[x].push_back(y);
    q[y].push_back(x);
  }
  ans = n;
  dfs(1, 0);
  int m;
  scanf("%d", &m);
  while (m--) {
    int x;
    double y;
    scanf("%d%lf", &x, &y);
    x++;
    ans += v[fa[x]] * vson[fa[x]] + v[x] * vson[x] + 1.0 - v[x];
    vson[fa[x]] -= v[x];
    v[x] = 1.0 - y;
    vson[fa[x]] += v[x];
    ans -= v[fa[x]] * vson[fa[x]] + v[x] * vson[x] + 1.0 - v[x];
    printf("%.6lf\n", ans);
  }
}
