#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
char buf[1 << 12], *pp1 = buf, *pp2 = buf, nc;
int ny;
inline char gc() { return getchar(); }
inline int read() {
  int x = 0;
  for (ny = 1; nc = gc(), (nc < 48 || nc > 57) && nc != EOF;)
    if (nc == 45) ny = -1;
  if (nc < 0) return nc;
  for (x = nc - 48; nc = gc(), 47 < nc && nc < 58 && nc != EOF;
       x = (x << 3) + (x << 1) + (nc ^ 48))
    ;
  return x * ny;
}
inline double readd() {
  double x;
  scanf("%lf", &x);
  return x;
}
int n, m, fa[MAXN];
double p[MAXN], ans, sum[MAXN];
vector<int> G[MAXN];
void dfs(int x, int f) {
  ans += p[x], fa[x] = f;
  for (auto y : G[x])
    if (y != f) dfs(y, x), sum[x] += p[y];
  ans -= p[x] * sum[x];
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) p[i] = 1 - readd();
  for (int i = 1; i <= n - 1; i++) {
    int x = read() + 1, y = read() + 1;
    G[x].push_back(y), G[y].push_back(x);
  }
  dfs(1, 0), m = read();
  for (int i = 1; i <= m; i++) {
    int x = read() + 1;
    double t = 1 - readd(), del = t - p[x];
    ans -= del * sum[x], ans -= del * p[fa[x]], ans += del, sum[fa[x]] += del,
        p[x] += del;
    printf("%.4lf\n", ans);
  }
  return 0;
}
