#include <bits/stdc++.h>
using namespace std;
const int MAXSIZE(1 << 20);
char buf[MAXSIZE], *p1, *p2;
inline int read() {
  register int ff = 0;
  register char ch =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2)
           ? EOF
           : *p1++);
  while (!isdigit(ch))
    ch =
        (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2)
             ? EOF
             : *p1++);
  while (isdigit(ch))
    ff = (ff << 1) + (ff << 3) + (ch ^ 48),
    ch =
        (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2)
             ? EOF
             : *p1++);
  return ff;
}
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 (register 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() {
  n = read();
  p[0] = 1;
  for (register int i(1); i <= n; ++i) scanf("%lf", p + i);
  for (register int i(1); i < n; ++i) {
    int u(read() + 1), v(read() + 1);
    son[u].push_back(v);
    son[v].push_back(u);
  }
  ans = 1 - p[1];
  dfs(1, 0);
  scanf("%d", &q);
  while (q--) {
    int k(read() + 1);
    double p1;
    scanf("%lf", &p1);
    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);
  }
}
