#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int data = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    data = (data << 3) + (data << 1) + (ch ^ 48), ch = getchar();
  return data * w;
}
const int maxn(1e5 + 10);
struct edge {
  int next, to;
} e[maxn << 1];
int head[maxn], e_num, n, m;
double p[maxn], sump, sume;
inline void add_edge(int from, int to) {
  e[++e_num] = (edge){head[from], to};
  head[from] = e_num;
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++)
    scanf("%lf", &p[i]), p[i] = 1 - p[i], sump += p[i];
  for (register int i = 1, a, b; i < n; i++)
    a = read() + 1, b = read() + 1, add_edge(a, b), add_edge(b, a),
    sume += p[a] * p[b];
  m = read();
  while (m--) {
    int a = read() + 1;
    double b;
    scanf("%lf", &b);
    sump = sump - p[a] + (1 - b);
    for (register int i = head[a]; i; i = e[i].next)
      sume = sume - p[a] * p[e[i].to] + (1 - b) * p[e[i].to];
    printf("%.5lf\n", sump - sume);
    p[a] = 1 - b;
  }
  return 0;
}
