#include <bits/stdc++.h>
using namespace std;
int n, q;
double p[100010], s[100010];
int x[100010], y[100010];
int d[100010];
vector<int> g[100010];
int main() {
  scanf("%d", &n);
  double sum = 0;
  for (int i = 0; i < n; i++) scanf("%lf", &p[i]), p[i] = 1 - p[i], sum += p[i];
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    d[x[i]]++, d[y[i]]++;
    sum -= p[x[i]] * p[y[i]];
  }
  for (int i = 1; i < n; i++) {
    if (d[x[i]] < d[y[i]]) swap(x[i], y[i]);
    g[y[i]].push_back(x[i]);
    s[x[i]] += p[y[i]];
  }
  int u;
  double d;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%lf", &u, &d);
    d = 1 - d;
    d = d - p[u];
    sum += d;
    sum -= d * s[u];
    p[u] += d;
    for (auto v : g[u]) {
      sum -= d * p[v];
      s[v] += d;
    }
    printf("%lf\n", sum);
  }
  return 0;
}
