#include <bits/stdc++.h>
using namespace std;
double dp[1000000], sum[1000000], ans;
int d[1000000], dis[1000000], vis[1000000], n, q;
vector<int> v[1000000];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lf", &dp[i]);
    dp[i] = 1 - dp[i];
    ans = ans + dp[i];
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &dis[i], &vis[i]);
    d[dis[i]]++;
    d[vis[i]]++;
  }
  for (int i = 1; i < n; i++) {
    if (d[dis[i]] < d[vis[i]]) {
      v[dis[i]].push_back(vis[i]);
      sum[vis[i]] = sum[vis[i]] + dp[dis[i]];
    } else {
      v[vis[i]].push_back(dis[i]);
      sum[dis[i]] = sum[dis[i]] + dp[vis[i]];
    }
  }
  for (int i = 1; i < n; i++) {
    ans = ans - dp[dis[i]] * dp[vis[i]];
  }
  scanf("%d", &q);
  vector<int>::iterator it;
  for (int i = 1, u; i <= q; i++) {
    double book = 0;
    scanf("%d", &u);
    book = sum[u];
    for (it = v[u].begin(); it != v[u].end(); ++it) {
      book = book + dp[*it];
      sum[*it] = sum[*it] - dp[u];
    }
    ans = ans + dp[u] * book;
    ans = ans - dp[u];
    scanf("%lf", &dp[u]);
    dp[u] = 1 - dp[u];
    ans = ans - dp[u] * book;
    ans = ans + dp[u];
    for (it = v[u].begin(); it != v[u].end(); ++it) {
      sum[*it] = sum[*it] + dp[u];
    }
    printf("%lf\n", ans);
  }
  return 0;
}
