#include <bits/stdc++.h>
using namespace std;
int n;
int pro[100001];
vector<int> edge[100001];
int sum[100001];
int par[100001];
void dfs(int x, int p) {
  par[x] = p;
  for (int i : edge[x]) {
    if (i == p) continue;
    dfs(i, x);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    double x;
    scanf("%lf", &x);
    pro[i] = llround(100 * (1 - x));
  }
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    ++x;
    ++y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  dfs(1, 0);
  int v = 0, e = 0;
  for (int i = 1; i <= n; ++i) {
    sum[par[i]] += pro[i];
  }
  for (int i = 1; i <= n; ++i) {
    v += pro[i];
    e += sum[i] * pro[i];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int x;
    double p;
    scanf("%d%lf", &x, &p);
    ++x;
    int pr = pro[x];
    v -= pro[x];
    e -= sum[par[x]] * pro[par[x]];
    e -= sum[x] * pro[x];
    pro[x] = llround(100 * (1 - p));
    sum[par[x]] += pro[x] - pr;
    v += pro[x];
    e += sum[par[x]] * pro[par[x]];
    e += sum[x] * pro[x];
    printf("%.5f\n", v / 100.0 - e / 10000.0);
  }
  return 0;
}
