#include <bits/stdc++.h>
using namespace std;
inline int Get() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m;
double p[100005];
struct load {
  int to, next;
} s[100005 << 1];
int h[100005], cnt;
void add(int i, int j) {
  s[++cnt] = (load){j, h[i]};
  h[i] = cnt;
}
int fa[100005];
double sum[100005];
void dfs(int v, int fr) {
  for (int i = h[v]; i; i = s[i].next) {
    int to = s[i].to;
    if (to == fr) continue;
    fa[to] = v;
    dfs(to, v);
    sum[v] += (1 - p[to]);
  }
}
double ans, c;
int main() {
  n = Get();
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  p[0] = 1;
  int a, b;
  for (int i = 1; i < n; i++) {
    a = Get() + 1, b = Get() + 1;
    add(a, b), add(b, a);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    ans += p[fa[i]] * (1 - p[i]);
  }
  m = Get();
  while (m--) {
    a = Get() + 1;
    scanf("%lf", &c);
    ans -= p[fa[a]] * (1 - p[a]);
    ans -= sum[a] * p[a];
    sum[fa[a]] -= 1 - p[a];
    p[a] = c;
    ans += p[fa[a]] * (1 - p[a]);
    ans += sum[a] * p[a];
    sum[fa[a]] += 1 - p[a];
    cout << ans << "\n";
  }
  return 0;
}
