#include <bits/stdc++.h>
using namespace std;
const int kNmax = 1e5 + 10;
int n, par[kNmax], q;
double prob[kNmax], sumSons[kNmax], ecc;
vector<int> g[kNmax];
void dfs(int node, int father) {
  par[node] = father;
  for (int vec : g[node]) {
    if (vec != father) {
      dfs(vec, node);
    }
  }
}
int main() {
  scanf("%d", &n);
  prob[0] = 1.0;
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &prob[i]);
  }
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d %d", &x, &y);
    x++;
    y++;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    sumSons[par[i]] += 1.0 - prob[i];
  }
  for (int i = 0; i <= n; i++) {
    ecc += prob[i] * sumSons[i];
  }
  scanf("%d", &q);
  for (; q; q--) {
    int node;
    double newProb;
    scanf("%d %lf", &node, &newProb);
    node++;
    ecc -= prob[par[node]] * sumSons[par[node]];
    ecc -= prob[node] * sumSons[node];
    sumSons[par[node]] -= 1.0 - prob[node];
    prob[node] = newProb;
    sumSons[par[node]] += 1.0 - prob[node];
    ecc += prob[par[node]] * sumSons[par[node]];
    ecc += prob[node] * sumSons[node];
    printf("%.10lf\n", ecc);
  }
}
