#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int N = 1e5 + 5, P = 500;
double p[N], sum[N];
vector<int> g[N], w[N];
bool vip[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  double ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i] = 1 - p[i];
    ans += p[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);
    ans -= p[a] * p[b];
  }
  for (int i = 0; i < n; i++) {
    if (g[i].size() > P) {
      vip[i] = 1;
      for (int to : g[i]) w[to].push_back(i);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int to : g[i]) {
      if (!vip[to]) sum[i] += p[to];
    }
  }
  int q;
  cin >> q;
  cout << fixed << setprecision(10);
  while (q--) {
    int x;
    double y;
    cin >> x >> y;
    y = 1 - y;
    ans += y - p[x];
    double s = sum[x];
    for (int to : w[x]) {
      s += p[to];
    }
    if (!vip[x]) {
      for (int to : g[x]) {
        sum[to] += y - p[x];
      }
    }
    ans = ans - s * y + p[x] * s;
    p[x] = y;
    cout << ans << "\n";
  }
  return 0;
}
