#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using D = float;
int n;
int parents[(int)1e5];
D p_fail[(int)1e5];
D contrib[(int)1e5];
vector<int> g[(int)1e5];
array<D, 2> dfs(int root, int parent) {
  parents[root] = parent;
  D expect_sum = 0;
  D expect_num = 0;
  for (auto child : g[root]) {
    if (child == parent) continue;
    auto expect = dfs(child, root);
    expect_sum += p_fail[child] * expect[0] + (1 - p_fail[child]) * expect[1];
    expect_num += 1 - p_fail[child];
  }
  contrib[root] = 1 - expect_num;
  return {expect_sum, expect_sum + contrib[root]};
}
D result;
D query(int node, D np_fail) {
  result -= (1 - p_fail[node]) * contrib[node];
  result += (1 - np_fail) * contrib[node];
  if (node != 0) {
    result -= (1 - p_fail[parents[node]]) * contrib[parents[node]];
    contrib[parents[node]] += (1 - p_fail[node]);
    contrib[parents[node]] -= (1 - np_fail);
    result += (1 - p_fail[parents[node]]) * contrib[parents[node]];
  }
  p_fail[node] = np_fail;
  return result;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> p_fail[i];
  for (int i = 0; i < (n - 1); i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  auto expect = dfs(0, -1);
  result = p_fail[0] * expect[0] + (1 - p_fail[0]) * expect[1];
  int q;
  cin >> q;
  cout << fixed << setprecision(15);
  for (int i = 0; i < (q); i++) {
    int node;
    D np_fail;
    cin >> node >> np_fail;
    cout << query(node, np_fail) << '\n';
  }
}
