#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
struct Matrix {
  double A[3][3];
  Matrix() { memset(A, 0, sizeof(A)); }
  void set() { A[0][0] = A[1][1] = A[2][2] = 1; }
  double *operator[](int x) { return A[x]; }
  Matrix operator*(Matrix &b) {
    Matrix c;
    c[0][0] = A[0][0] * b[0][0] + A[0][1] * b[1][0];
    c[0][1] = A[0][0] * b[0][1] + A[0][1] * b[1][1];
    c[0][2] = A[0][0] * b[0][2] + A[0][1] * b[1][2] + A[0][2];
    c[1][0] = A[1][0] * b[0][0] + A[1][1] * b[1][0];
    c[1][1] = A[1][0] * b[0][1] + A[1][1] * b[1][1];
    c[1][2] = A[1][0] * b[0][2] + A[1][1] * b[1][2] + A[1][2];
    c[2][0] = 0;
    c[2][1] = 0;
    c[2][2] = 1;
    return c;
  }
};
int prt[MAXN], ch[MAXN][2];
Matrix A[MAXN], F[MAXN];
double g[MAXN][2], f[MAXN][2];
double p[MAXN];
bool isroot(int x) { return ch[prt[x]][0] != x && ch[prt[x]][1] != x; }
void Set(int u, int son = 0) {
  A[u][0][0] = p[u];
  A[u][0][1] = p[u];
  A[u][0][2] = p[u] * g[u][0];
  A[u][1][0] = 1 - p[u];
  A[u][1][1] = 1 - p[u];
  A[u][1][2] = (1 - p[u]) * (g[u][1] + 1 - (son != 0) * (1 - p[son]));
  A[u][2][0] = 0;
  A[u][2][1] = 0;
  A[u][2][2] = 1;
}
void Maintain(int x) {
  F[x] = F[ch[x][0]] * A[x] * F[ch[x][1]];
  Matrix tmp = F[ch[x][0]] * A[x];
  f[x][0] = tmp[0][0] * f[ch[x][1]][0] + tmp[0][1] * f[ch[x][1]][1] + tmp[0][2];
  f[x][1] = tmp[1][0] * f[ch[x][1]][0] + tmp[1][1] * f[ch[x][1]][1] + tmp[1][2];
}
void Rot(int x) {
  int f = prt[x], g = prt[f];
  int L = ch[f][0] != x, R = L ^ 1;
  if (!isroot(f)) ch[g][ch[g][0] != f] = x;
  prt[x] = g;
  prt[f] = x;
  prt[ch[x][R]] = f;
  ch[f][L] = ch[x][R];
  ch[x][R] = f;
  Maintain(f);
  Maintain(x);
}
void Splay(int x, int s = 0) {
  if (!s) {
    while (!isroot(x)) {
      int f = prt[x], g = prt[f];
      if (!isroot(f))
        if (ch[f][0] == x ^ ch[g][0] == f)
          Rot(x);
        else
          Rot(f);
      else
        Rot(x);
    }
  } else {
    while (prt[x] != s) {
      int f = prt[x], g = prt[f];
      if (g != s)
        if (ch[f][0] == x ^ ch[g][0] == f)
          Rot(x);
        else
          Rot(f);
      else
        Rot(x);
    }
  }
}
void Shift(int u, int v, int opt) {
  if (!v) return;
  g[u][0] += opt * (f[v][0] + f[v][1]);
  g[u][1] += opt * (f[v][0] + f[v][1] - (1 - p[v]));
}
int Top(int x) {
  while (ch[x][0]) x = ch[x][0];
  return x;
}
void Access(int x) {
  int t = 0;
  while (x) {
    Splay(x);
    if (ch[x][1]) {
      Splay(Top(ch[x][1]), x);
      Shift(x, ch[x][1], +1);
    }
    ch[x][1] = t;
    if (ch[x][1]) {
      Splay(Top(ch[x][1]), x);
      Shift(x, ch[x][1], -1);
    }
    Set(x, ch[x][1]);
    Maintain(x);
    t = x;
    x = prt[x];
  }
}
void Link(int u, int v) {
  prt[v] = u;
  Shift(u, v, +1);
  Access(v);
}
vector<int> T[MAXN];
void Dfs(int u, int p) {
  for (int i = 0; i < T[u].size(); i++) {
    int v = T[u][i];
    if (v == p) continue;
    Link(u, v);
    Dfs(v, u);
  }
}
int pre(int x) {
  int p = ch[x][0];
  while (ch[p][1]) p = ch[p][1];
  return p;
}
int main() {
  F[0].set();
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &p[i]);
    Set(i);
    Maintain(i);
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u++, v++;
    T[u].push_back(v);
    T[v].push_back(u);
  }
  Dfs(1, 0);
  int q;
  scanf("%d", &q);
  while (q--) {
    int u;
    double x;
    scanf("%d%lf", &u, &x);
    u++;
    Access(u);
    Splay(u);
    p[u] = x;
    int tmp = pre(u);
    if (tmp) {
      Splay(tmp);
      Set(tmp, u);
      Maintain(tmp);
    }
    Splay(u);
    Set(u);
    Maintain(u);
    printf("%.4f\n", f[u][0] + f[u][1]);
  }
  return 0;
}
