#include <bits/stdc++.h>
using namespace std;
vector<int> vect[100010];
bool pos[100010];
int n, parent[100010], a, b, q;
float surv[100010], prob, rez, sum[100010];
void dfs(int x, int prev) {
  pos[x] = 1;
  parent[x] = prev;
  for (int i = 0; i < vect[x].size(); i++) {
    if (pos[vect[x][i]]) continue;
    sum[x] += surv[vect[x][i]];
    dfs(vect[x][i], x);
  }
  rez -= (sum[x] * surv[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%f", &prob);
    surv[i] = 1 - prob;
    rez += surv[i];
  }
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &a, &b);
    a++;
    b++;
    vect[a].push_back(b);
    vect[b].push_back(a);
  }
  int root = 1;
  dfs(root, 0);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d %f", &a, &prob);
    prob = 1 - prob;
    a++;
    rez += sum[a] * surv[a];
    rez -= sum[a] * prob;
    rez -= surv[a];
    rez += prob;
    if (parent[a] != 0) {
      rez += sum[parent[a]] * surv[parent[a]];
      sum[parent[a]] -= surv[a];
      sum[parent[a]] += prob;
      rez -= sum[parent[a]] * surv[parent[a]];
    }
    surv[a] = prob;
    printf("%f\n", rez);
  }
  return 0;
}
