#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 19;
int pa[MAXN];
bool visited[MAXN];
vector<int> adj[MAXN];
double pp[MAXN], p[MAXN];
void dfs(int n) {
  cout << n << endl;
  visited[n] = true;
  for (auto& it : adj[n]) {
    if (!visited[it]) {
      pp[n] += p[it];
      pa[it] = n;
      dfs(it);
    }
  }
  return;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  cout << setprecision(20);
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> p[i];
  for (int i = 0; i < (n - 1); ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int q;
  cin >> q;
  pa[0] = -1;
  dfs(0);
  double ans = 0;
  for (int i = 1; i <= (n - 1); ++i) {
    ans += p[pa[i]] * (1 - p[i]);
  }
  ans += (1 - p[0]);
  for (int i = 0; i < (q); ++i) {
    int in;
    cin >> in;
    double np;
    cin >> np;
    if (in == 0) {
      ans -= (1 - p[0]);
      ans += (1 - np);
      ans -= p[0] * ((int)(adj[0]).size() - pp[0]);
      ans += np * ((int)(adj[0]).size() - pp[0]);
      p[0] = np;
    } else {
      ans -= p[pa[in]] * (1 - p[in]);
      ans += p[pa[in]] * (1 - np);
      pp[pa[in]] -= p[in];
      pp[pa[in]] += np;
      if ((int)(adj[in]).size() != 0) {
        ans -= p[in] * (((int)(adj[in]).size() - 1) - pp[in]);
        ans += np * (((int)(adj[in]).size() - 1) - pp[in]);
      }
      p[in] = np;
    }
    cout << ans << endl;
  }
  return 0;
}
