#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int arr = 2e5 + 10;
const int ar = 2e3 + 10;
const long double pi = acos(-1);
const long double eps = 1e-10;
const long long md = 1e9 + 7;
const int bsize = 450;
double p[arr];
vector<int> reb[arr];
bool big[arr];
vector<int> big_nei[arr];
double sum[arr];
int main() {
  int n;
  scanf("%d", &n);
  double ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lf", &p[i]);
    p[i] = 1 - p[i];
    ans += p[i];
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    reb[u].push_back(v);
    reb[v].push_back(u);
    ans -= p[u] * p[v];
    sum[u] += p[v];
    sum[v] += p[u];
  }
  for (int i = 0; i < n; i++) {
    big[i] = ((int)(reb[i].size()) > bsize);
  }
  for (int i = 0; i < n; i++) {
    if (big[i]) {
      for (auto wh : reb[i]) {
        big_nei[wh].push_back(i);
      }
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int v;
    double new_p;
    scanf("%d%lf", &v, &new_p);
    new_p = 1 - new_p;
    ans += new_p - p[v];
    if (big[v]) {
      ans -= sum[v] * (new_p - p[v]);
    } else {
      for (auto wh : reb[v]) {
        ans -= p[wh] * (new_p - p[v]);
      }
    }
    for (auto wh : big_nei[v]) {
      sum[wh] += new_p - p[v];
    }
    p[v] = new_p;
    cout << fixed << setprecision(10) << ans << "\n";
  }
}
