#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const long long LINF = LLONG_MAX;
const int N = 1e5 + 20;
vector<int> G[N];
double p[N], f[N], ans;
int n, q, dad[N];
void dfs(int v, int r = -1) {
  dad[v] = r;
  if (r + 1)
    ans += (1 - p[v]) * p[r];
  else
    ans += (1 - p[v]);
  for (int u : G[v])
    if (u != r) {
      f[v] += (1 - p[u]);
      dfs(u, v);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lf", &p[i]);
  for (int i = 0, v, u; i < n - 1; i++) {
    scanf("%d%d", &v, &u);
    G[v].push_back(u);
    G[u].push_back(v);
  }
  dfs(0);
  scanf("%d", &q);
  while (q--) {
    int v;
    double x;
    scanf("%d%lf", &v, &x);
    if (dad[v] + 1) {
      f[dad[v]] += (1 - x);
      f[dad[v]] -= (1 - p[v]);
    }
    ans -= p[v] * f[v];
    ans += x * f[v];
    if (dad[v] + 1) {
      ans -= (1 - p[v]) * p[dad[v]];
      ans += (1 - x) * p[dad[v]];
    } else {
      ans -= (1 - p[v]);
      ans += (1 - x);
    }
    p[v] = x;
    printf("%lf\n", ans);
  }
}
