#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = true, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
struct Line {
  int v, next;
} e[100100 << 1];
int h[100100], cnt = 1;
inline void Add(int u, int v) {
  e[cnt] = (Line){v, h[u]};
  h[u] = cnt++;
}
int fa[100100], n, Q;
double p[100100], V, E, s[100100];
void dfs(int u, int ff) {
  fa[u] = ff;
  for (int i = h[u]; i; i = e[i].next) {
    int v = e[i].v;
    if (v == ff) continue;
    dfs(v, u);
    E += p[u] * p[v];
    s[u] += p[v];
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) scanf("%lf", &p[i]), V += (p[i] = 1 - p[i]);
  for (int i = 1; i < n; ++i) {
    int u = read() + 1, v = read() + 1;
    Add(u, v);
    Add(v, u);
  }
  dfs(1, 0);
  Q = read();
  while (Q--) {
    int u = read() + 1;
    double P;
    scanf("%lf", &P);
    P = 1 - P;
    V -= p[u];
    V += P;
    E -= p[u] * s[u];
    E -= p[u] * p[fa[u]];
    if (fa[u]) s[fa[u]] -= p[u], s[fa[u]] += P;
    p[u] = P;
    E += p[u] * p[fa[u]];
    E += p[u] * s[u];
    printf("%.10lf\n", V - E);
  }
  return 0;
}
