#include <bits/stdc++.h>
using namespace std;
double p[200010], sum[200010];
int tot = 1;
double ans = 0;
int fir[200010], nex[200010], got[200010], par[200010];
inline void AddEdge(int x, int y) {
  nex[++tot] = fir[x], fir[x] = tot, got[tot] = y;
}
inline void dfs(int x, int fa) {
  par[x] = fa;
  for (int i = fir[x]; i; i = nex[i]) {
    int y = got[i];
    if (y == fa) continue;
    dfs(y, x), sum[x] += 1 - p[y];
  }
  ans += p[fa] * (1 - p[x]);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    AddEdge(++x, ++y), AddEdge(y, x);
  }
  p[0] = 1, dfs(1, 0);
  int m;
  cin >> m;
  while (m--) {
    int x;
    double y;
    scanf("%d %lf", &x, &y);
    ++x;
    ans -= sum[x] * p[x];
    ans -= p[par[x]] * (1 - p[x]);
    p[x] = y;
    ans += sum[x] * p[x];
    ans += p[par[x]] * (1 - p[x]);
    printf("%lf\n", ans);
  }
  return 0;
}
