#include <bits/stdc++.h>
using namespace std;
int N, Q, parent[100010];
double rez, p[100010], f[100010];
vector<int> adj[100010];
void DFS(int node, int prev) {
  parent[node] = prev;
  for (auto x : adj[node]) {
    if (x != prev) {
      DFS(x, node);
      f[node] += p[x];
    }
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%lf", &p[i]);
    fprintf(stderr, "%s = %f\n", "p[i]", p[i]);
    ;
    p[i] = 1 - p[i];
    rez += p[i];
  }
  for (int i = 1; i <= N - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
    rez -= p[x] * p[y];
  }
  DFS(0, N);
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    int x;
    double pp;
    scanf("%d%lf", &x, &pp);
    pp = 1 - pp;
    double dp = pp - p[x];
    rez = rez + dp * (1 - f[x] - p[parent[x]]);
    f[parent[x]] += dp;
    p[x] = pp;
    printf("%.5f\n", rez);
  }
  return 0;
}
