#include <bits/stdc++.h>
using namespace std;
inline void rd(int &x) {
  static char c;
  x = 0;
  while (c = getchar(), c < 48)
    ;
  do x = (x << 3) + (x << 1) + (c ^ 48);
  while (c = getchar(), c > 47);
}
inline void pt(int x) {
  if (!x) putchar('0');
  static int Stk[30], tp = 0;
  for (; x; x /= 10) Stk[tp++] = x % 10;
  while (tp) putchar(Stk[--tp] ^ 48);
}
inline void ptk(const int &x) {
  pt(x);
  putchar(' ');
}
inline void ptn(const int &x) {
  pt(x);
  putchar('\n');
}
inline bool chkmx(int &x, const int &y) { return x < y ? x = y, true : false; }
inline bool chkmi(int &x, const int &y) { return x > y ? x = y, true : false; }
const int M = (int)2e5 + 500;
int Head[M], E[M << 1], Nxt[M << 1], tol;
void Edge(int x, int y) {
  E[tol] = y;
  Nxt[tol] = Head[x];
  Head[x] = tol++;
}
int Fa[M], sz[M];
void dfs(int x, int fr) {
  Fa[x] = fr;
  for (int i = Head[x]; ~i; i = Nxt[i])
    if (E[i] != fr) {
      sz[x]++;
      dfs(E[i], x);
    }
}
double sum[M], Tmp[M];
double tot[M];
double P[M], in[M];
double res;
void Update(int x, double p) {
  int f = Fa[x], ff = Fa[f];
  res -= P[x] * (tot[x] + P[f] - 1 + Tmp[x] * (1 - P[f]));
  res -= P[x] * (tot[x] + P[f]);
  res -= (1 - P[x]) * sum[x];
  res -= P[f] * Tmp[f] * (1 - P[ff]);
  if (ff) sum[ff] -= P[f] * Tmp[f];
  if (f) Tmp[f] = Tmp[f] / (1 - P[x]) * (1 - p);
  if (ff) sum[ff] += P[f] * Tmp[f];
  if (f) tot[f] -= P[x];
  if (f) tot[f] += p;
  P[x] = p;
  res += P[x] * (tot[x] + P[f] - 1 + Tmp[x] * (1 - P[f]));
  res += P[x] * (tot[x] + P[f]);
  res += (1 - P[x]) * sum[x];
  res += P[f] * Tmp[f] * (1 - P[ff]);
}
int main() {
  memset(Head, -1, sizeof(Head));
  int n;
  rd(n);
  for (int i = (1), _t = (n); i <= _t; ++i) scanf("%lf", &in[i]);
  for (int i = (2), _t = (n); i <= _t; ++i) {
    int x, y;
    rd(x);
    rd(y);
    x++;
    y++;
    Edge(x, y);
    Edge(y, x);
  }
  for (int i = (1), _t = (n); i <= _t; ++i) Tmp[i] = 1;
  dfs(1, 0);
  res = 1;
  for (int i = (1), _t = (n); i <= _t; ++i) Update(i, in[i]);
  int q;
  rd(q);
  for (int i = (1), _t = (q); i <= _t; ++i) {
    int x;
    double p;
    x++;
    scanf("%d%lf", &x, &p);
    Update(x, p);
    printf("%.5lf\n", res);
  }
  return 0;
}
