#include <bits/stdc++.h>
using namespace std;
int _min(int x, int y) { return x < y ? x : y; }
int _max(int x, int y) { return x > y ? x : y; }
int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * f;
}
struct edge {
  int x, y, next;
} e[210000];
int len, last[110000];
int n, id, deg[110000], tt[110000], L[110000], R[110000];
double p[110000], s[110000];
int fa[110000];
queue<int> q;
void ins(int x, int y) {
  e[++len].x = x, e[len].y = y;
  e[len].next = last[x], last[x] = len;
}
void bfs() {
  q.push(1);
  tt[1] = 1;
  id = 1;
  memset(R, 0, sizeof(R));
  memset(L, 63, sizeof(L));
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int k = last[x]; k; k = e[k].next) {
      int y = e[k].y;
      if (y != fa[x]) {
        tt[y] = ++id;
        fa[y] = x;
        L[x] = _min(L[x], id);
        R[x] = _max(R[x], id);
        q.push(y);
      }
    }
  }
}
int lowbit(int x) { return x & -x; }
void change(int x, double c) {
  for (int i = x; i <= n; i += lowbit(i)) s[i] += c;
}
double getsum(int x) {
  double ans = 0;
  for (int i = x; i; i -= lowbit(i)) ans += s[i];
  return ans;
}
int main() {
  n = read();
  double V = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &p[i]);
    p[i] = 1.0 - p[i];
    V += p[i];
  }
  double E = 0;
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    x++, y++;
    E += p[x] * p[y];
    ins(x, y), ins(y, x);
    deg[x]++, deg[y]++;
  }
  bfs();
  for (int i = 1; i <= n; i++) {
    if (R[i] == 0) R[i] = tt[i];
    if (L[i] > n) L[i] = tt[i] + 1;
  }
  for (int i = 1; i <= n; i++) change(tt[i], p[i]);
  int q = read();
  for (int i = 1; i <= q; i++) {
    int x = read();
    double yy;
    x++;
    scanf("%lf", &yy);
    yy = 1.0 - yy;
    double u = p[x];
    V -= p[x], p[x] = yy, V += p[x];
    if (x != 1) {
      E -= p[fa[x]] * u;
      E += p[fa[x]] * yy;
      double sum = getsum(R[x]) - getsum(L[x] - 1);
      E -= sum * u;
      E += sum * yy;
    } else {
      double sum = getsum(R[x]) - getsum(L[x] - 1);
      E -= sum * u;
      E += sum * yy;
    }
    change(tt[x], yy - u);
    printf("%.5lf\n", V - E);
  }
  return 0;
}
