#include <bits/stdc++.h>
using namespace std;
struct line {
  int v, next;
} e[200005];
int b[100005], t, f[100005], n, x, y, m;
double s[100005], w[100005];
inline void build(int x, int y) { e[++t].v = y, e[t].next = b[x], b[x] = t; }
void dfs(int u) {
  for (int o = b[u]; o != -1; o = e[o].next) {
    int v = e[o].v;
    if (v == f[u]) continue;
    f[v] = u;
    dfs(v);
  }
}
int main() {
  scanf("%d", &n);
  double ac = 0;
  for (int i = 1; i <= n; i++) scanf("%lf", &w[i]), ac += w[i] = 1 - w[i];
  memset(b, -1, sizeof b);
  t = -1;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    ++x, ++y;
    build(x, y), build(y, x);
  }
  dfs(1);
  for (int i = 2; i <= n; i++) s[f[i]] += w[i], ac -= w[i] * w[f[i]];
  scanf("%d", &m);
  while (m--) {
    scanf("%d", &x);
    ++x;
    ac -= w[x] - (s[x] + w[f[x]]) * w[x];
    s[f[x]] -= w[x];
    scanf("%lf", &w[x]);
    w[x] = 1 - w[x];
    ac += w[x] - (s[x] + w[f[x]]) * w[x];
    s[f[x]] += w[x];
    printf("%.8lf\n", ac);
  }
  return 0;
}
