#include <bits/stdc++.h>
using namespace std;
double fall[100005];
double sumaround[100005];
int main() {
  int n;
  scanf("%d", &n);
  vector<vector<int> > graph(n, vector<int>());
  vector<vector<int> > graph2(n, vector<int>());
  double sum2 = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lf", &fall[i]);
    sum2 += fall[i];
  }
  double sum = 0;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    graph[a].push_back(b);
    graph[b].push_back(a);
    sumaround[a] += (1 - fall[b]);
    sumaround[b] += (1 - fall[a]);
    sum += (1 - fall[a]) * (1 - fall[b]);
  }
  for (int i = 0; i < n; i++) {
    if (graph[i].size() >= 250) {
      for (int u : graph[i]) {
        graph2[u].push_back(i);
      }
    }
  }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int x;
    double p;
    scanf("%d %lf", &x, &p);
    sum2 += p - fall[x];
    double cursum = 0;
    if (graph[x].size() > 250) {
      cursum = sumaround[x];
    } else {
      for (int u : graph[x]) {
        cursum += 1 - fall[u];
      }
    }
    for (int u : graph2[x]) {
      sumaround[u] += fall[x] - p;
    }
    sum -= (1 - fall[x]) * cursum;
    sum += (1 - p) * cursum;
    fall[x] = p;
    printf("%.6f\n", n - sum - sum2);
  }
  return 0;
}
