#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, mod = 1e9 + 7;
vector<int> g[N];
int par[N], st[N], now = 0, n;
float p[N], sum[N], seg[4 * N];
void add(int s, int e, int ind, int l, int r, double val) {
  if (s >= r || e <= l) return;
  if (s >= l && e <= r) {
    seg[ind] += val;
    return;
  }
  int mid = (s + e) / 2;
  if (mid > l) add(s, mid, 2 * ind, l, r, val);
  if (mid < r) add(mid, e, 2 * ind + 1, l, r, val);
  seg[ind] = seg[2 * ind] + seg[2 * ind + 1];
}
void dfs(int v, int pp) {
  st[v] = now++;
  par[v] = pp;
  for (int u : g[v])
    if (u != pp) {
      dfs(u, v);
      sum[v] += p[u];
    }
  add(0, n, 1, st[v], st[v] + 1, p[v] * double(1 - sum[v]));
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(6);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%f", &p[i]);
    p[i] = 1 - p[i];
  }
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0, 0);
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int x;
    float pp;
    scanf("%d%f", &x, &pp);
    pp = 1 - pp;
    if (x) {
      int pr = par[x];
      add(0, n, 1, st[pr], st[pr] + 1, -p[pr] * double(1 - sum[pr]));
      sum[pr] = sum[pr] - p[x] + pp;
      add(0, n, 1, st[pr], st[pr] + 1, p[pr] * double(1 - sum[pr]));
    }
    add(0, n, 1, st[x], st[x] + 1, -p[x] * double(1 - sum[x]));
    p[x] = pp;
    add(0, n, 1, st[x], st[x] + 1, p[x] * double(1 - sum[x]));
    printf("%f\n", seg[1]);
  }
  return 0;
}
