#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, pr[N];
double p[N], allSum, sum2, sum[N];
vector<int> g[N];
void dfs(int v, int curP) {
  pr[v] = curP;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to == curP) continue;
    sum[v] += p[to];
    dfs(to, v);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i] = 1 - p[i];
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0, -1);
  for (int i = 0; i < n; i++) {
    allSum += p[i];
    sum2 += p[i] * sum[i];
  }
  int tt;
  cin >> tt;
  while (tt--) {
    int v;
    double x;
    cin >> v >> x;
    x = 1 - x;
    if (pr[v] != -1) {
      sum2 -= p[pr[v]] * sum[pr[v]];
      sum[pr[v]] -= p[v];
      sum[pr[v]] += x;
      sum2 += p[pr[v]] * sum[pr[v]];
    }
    allSum -= p[v];
    sum2 -= p[v] * sum[v];
    p[v] = x;
    allSum += p[v];
    sum2 += p[v] * sum[v];
    printf("%.5f\n", allSum - sum2);
  }
}
