#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int k = 0;
  char ch = getchar();
  while (ch < '-') ch = getchar();
  while (ch > '-') k = k * 10 + ch - '0', ch = getchar();
  return k;
}
const int N = 1e5 + 5;
int head[N], to[N << 1], nxt[N << 1], cnt;
double sum = 0;
double p[N];
inline void add(int u, int v) {
  to[++cnt] = v, nxt[cnt] = head[u], head[u] = cnt;
  to[++cnt] = u, nxt[cnt] = head[v], head[v] = cnt;
  sum -= (1 - p[u]) * (1 - p[v]);
}
int main() {
  int n = in();
  for (int i = 1; i <= n; i++) scanf("%lf", p + i);
  for (int i = 1; i < n; i++) add(in() + 1, in() + 1);
  for (int i = 1; i <= n; i++) sum += (1.0 - p[i]);
  int Q = in();
  while (Q--) {
    int u = in() + 1;
    double P;
    scanf("%lf", &P);
    for (int i = head[u]; i; i = nxt[i]) sum += (1.0 - p[u]) * (1.0 - p[to[i]]);
    sum -= (1.0 - p[u]);
    p[u] = P;
    sum += (1.0 - p[u]);
    for (int i = head[u]; i; i = nxt[i]) sum -= (1.0 - p[u]) * (1.0 - p[to[i]]);
    printf("%.5lf\n", sum);
  }
  return 0;
}
