#include <bits/stdc++.h>
using namespace std;
vector<long double> prob(100005);
vector<vector<long long>> graph(100005);
vector<long long> par(100005);
vector<long double> arr(100005);
void dfs(long long ver, long long pari) {
  par[ver] = pari;
  for (auto i : graph[ver]) {
    if (i == pari) continue;
    dfs(i, ver);
    prob[ver] += arr[i];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i], arr[i] = 1 - arr[i];
  for (int i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  long double res = 0;
  dfs(0, -1);
  for (int i = 0; i < n; i++) {
    res += arr[i] - arr[i] * prob[i];
  }
  long long q;
  cin >> q;
  while (q--) {
    long long ver;
    long double pro;
    cin >> ver >> pro;
    pro = 1 - pro;
    if (par[ver] != -1) {
      res += arr[par[ver]] * arr[ver];
      prob[par[ver]] -= arr[ver];
    }
    res -= (arr[ver] - arr[ver] * prob[ver]);
    arr[ver] = pro;
    res += (arr[ver] - arr[ver] * prob[ver]);
    if (par[ver] != -1) {
      res -= arr[par[ver]] * arr[ver];
      prob[par[ver]] += arr[ver];
    }
    cout << fixed << setprecision(5) << res << '\n';
  }
  return 0;
}
