#include <bits/stdc++.h>
using namespace std;
int head[100001], nxt[100001 << 1], ver[100001 << 1], tot;
int n;
inline void addedge(int a, int b) {
  nxt[++tot] = head[a];
  ver[tot] = b;
  head[a] = tot;
  nxt[++tot] = head[b];
  ver[tot] = a;
  head[b] = tot;
}
double a[100001];
inline void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", a + i);
  for (int i = 1, a, b; i < n; i++)
    scanf("%d%d", &a, &b), a++, b++, addedge(a, b);
}
double f[100001][2];
int fa[100001];
inline void update(int x) {
  f[x][1] = 1;
  f[x][0] = 0;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y == fa[x]) continue;
    f[x][0] += a[y] * f[y][0] + (1.0 - a[y]) * f[y][1];
    f[x][1] += a[y] * f[y][0] + (1.0 - a[y]) * (f[y][1] - 1);
  }
  if (fa[x]) update(fa[x]);
}
inline void dp(int x, int fat) {
  f[x][1] = 1;
  f[x][0] = 0;
  fa[x] = fat;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y == fat) continue;
    dp(y, x);
    f[x][0] += a[y] * f[y][0] + (1.0 - a[y]) * f[y][1];
    f[x][1] += a[y] * f[y][0] + (1.0 - a[y]) * (f[y][1] - 1);
  }
}
int main() {
  init();
  dp(1, 0);
  int q;
  cin >> q;
  while (q--) {
    int x;
    scanf("%d", &x);
    x++;
    scanf("%lf", a + x);
    update(x);
    printf("%0.5f\n", a[1] * f[1][0] + (1.0 - a[1]) * f[1][1]);
  }
}
