#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100005;
double p[Maxn], g[Maxn][2];
int h[Maxn], prt[Maxn];
int son[Maxn], top[Maxn], btm[Maxn], mark[Maxn], id[Maxn];
struct matrix {
  double a[3][3];
  matrix() {
    a[0][0] = 1;
    a[0][1] = 0;
    a[0][2] = 0;
    a[1][0] = 0;
    a[1][1] = 1;
    a[1][2] = 0;
    a[2][0] = 0;
    a[2][1] = 0;
    a[2][2] = 1;
  }
  void clear() {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++) a[i][j] = 0;
  }
  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;
  }
  matrix mul(matrix b) {
    matrix c;
    c.clear();
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        for (int k = 0; k < 3; k++) c[i][j] += a[i][k] * b[k][j];
    return c;
  }
} w[Maxn], r[Maxn];
struct node {
  int to, next;
} e[Maxn * 2];
struct tree {
  int l, r, Min, Max;
  matrix w;
} Tree[Maxn * 4];
void AddEdge(int x, int y) {
  static int cnt;
  e[++cnt] = {y, h[x]};
  h[x] = cnt;
}
void rebuild(matrix& w, int x) {
  if (!son[x]) return;
  w[0][0] = p[x];
  w[0][1] = p[x];
  w[0][2] = p[x] * g[x][0];
  w[1][0] = 1 - p[x];
  w[1][1] = 1 - p[x];
  w[1][2] = (1 - p[x]) * (g[x][1] + p[son[x]]);
  w[2][0] = 0;
  w[2][1] = 0;
  w[2][2] = 1;
}
void Add(int x, matrix& a, int op) {
  if (x == son[prt[x]]) return;
  g[prt[x]][0] += op * (a[0][0] + a[1][0]);
  g[prt[x]][1] += op * (a[0][0] + a[1][0] - (1 - p[x]));
}
void dfs1(int x, int fa) {
  static int Size[Maxn];
  prt[x] = fa;
  Size[x] = 1;
  for (int p = h[x]; p; p = e[p].next) {
    int y = e[p].to;
    if (y == fa) continue;
    dfs1(y, x);
    Size[x] += Size[y];
    if (Size[y] > Size[son[x]]) son[x] = y;
  }
}
void dfs2(int x, int top) {
  static int cnt;
  static double f[Maxn][2];
  ::top[x] = top;
  btm[top] = x;
  mark[x] = ++cnt;
  id[cnt] = x;
  f[x][0] = 0;
  f[x][1] = 1 - p[x];
  if (son[x]) {
    dfs2(son[x], top);
    f[x][0] += p[x] * (f[son[x]][0] + f[son[x]][1]);
    f[x][1] += (1 - p[x]) * (f[son[x]][0] + f[son[x]][1] - 1 + p[son[x]]);
  }
  for (int p = h[x]; p; p = e[p].next) {
    int y = e[p].to;
    if (y == prt[x] || y == son[x]) continue;
    dfs2(y, y);
    f[x][0] += ::p[x] * (f[y][0] + f[y][1]);
    f[x][1] += (1 - ::p[x]) * (f[y][0] + f[y][1] - 1 + ::p[y]);
  }
  if (x != son[prt[x]]) {
    g[prt[x]][0] += f[x][0] + f[x][1];
    g[prt[x]][1] += f[x][0] + f[x][1] - (1 - p[x]);
  }
  r[x][0][0] = f[x][0];
  r[x][1][0] = f[x][1];
  r[x][2][0] = 1;
}
void PushUp(int v) {
  if (Tree[v].Max != Tree[v].Min) return;
  Tree[v].w = Tree[2 * v].w * Tree[2 * v + 1].w;
}
void Build(int v, int l, int r) {
  Tree[v] = {l, r};
  if (l == r) {
    Tree[v] = {l, r, top[id[l]], top[id[l]]};
    rebuild(Tree[v].w, id[l]);
    return;
  }
  Build(2 * v, l, (l + r) / 2);
  Build(2 * v + 1, (l + r) / 2 + 1, r);
  Tree[v].Max = max(Tree[2 * v].Max, Tree[2 * v + 1].Max);
  Tree[v].Min = max(Tree[2 * v].Min, Tree[2 * v + 1].Min);
  PushUp(v);
}
void Modify(int v, int pos) {
  if (pos < Tree[v].l || Tree[v].r < pos) return;
  if (Tree[v].l == Tree[v].r) {
    rebuild(Tree[v].w, id[pos]);
    return;
  }
  Modify(2 * v, pos);
  Modify(2 * v + 1, pos);
  PushUp(v);
}
matrix Ask(int v, int l, int r) {
  if (r < Tree[v].l || Tree[v].r < l) return matrix();
  if (l <= Tree[v].l && Tree[v].r <= r) return Tree[v].w;
  return Ask(2 * v, l, r) * Ask(2 * v + 1, l, r);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x++, y++;
    AddEdge(x, y);
    AddEdge(y, x);
  }
  dfs1(1, 0);
  dfs2(1, 1);
  Build(1, 1, n);
  int m;
  scanf("%d", &m);
  while (m--) {
    int x;
    double op = p[x], np;
    scanf("%d%lf", &x, &np);
    x++;
    if (x == top[x]) {
      Add(x, r[x], -1);
      p[x] = np;
      Modify(1, mark[x]);
      matrix roll = Ask(1, mark[x], mark[btm[x]]);
      r[x] = roll.mul(r[btm[x]]);
      Add(x, r[x], 1);
    } else {
      p[x] = np;
      Modify(1, mark[x]);
      Modify(1, mark[prt[x]]);
    }
    while (x) {
      Modify(1, mark[x]);
      if (x == btm[top[x]] && x == top[x]) {
        Add(x, r[x], -1);
        r[x][0][0] = p[x] * g[x][0];
        r[x][1][0] = (1 - p[x]) * (1 + g[x][1]);
        r[x][2][0] = 1;
        Add(x, r[x], +1);
        x = prt[x];
        continue;
      }
      if (x == btm[top[x]]) {
        r[x][0][0] = p[x] * g[x][0];
        r[x][1][0] = (1 - p[x]) * (1 + g[x][1]);
        r[x][2][0] = 1;
        x = top[x];
      } else if (x == top[x]) {
        Add(x, r[x], -1);
        matrix roll = Ask(1, mark[x], mark[btm[x]]);
        r[x] = roll.mul(r[btm[x]]);
        Add(x, r[x], +1);
        x = prt[x];
      } else {
        x = top[x];
      }
    }
    printf("%.5f\n", r[1][0][0] + r[1][1][0]);
  }
  return 0;
}
