#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
double p[MAXN];
vector<int> adj[MAXN];
int f[MAXN];
double ans;
void dfs(int v, int p = 0) {
  f[v] = p;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (u != p) {
      dfs(u, v);
    }
  }
}
void change(int v, double g) {
  ans -= (1 - p[v]) * p[f[v]];
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (u == f[v]) {
      continue;
    }
    ans -= (1 - p[u]) * p[v];
  }
  p[v] = g;
  ans += (1 - p[v]) * p[f[v]];
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (u == f[v]) {
      continue;
    }
    ans += (1 - p[u]) * p[v];
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &p[i]);
  }
  p[0] = 1;
  int u, v;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &u);
    scanf("%d", &v);
    u++;
    v++;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    ans += (1 - p[i]) * p[f[i]];
  }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &v);
    double z;
    scanf("%lf", &z);
    v++;
    change(v, z);
    printf("%.4lf\n", ans);
  }
}
