#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout.setf(ios::fixed);
  cout.precision(12);
  vector<vector<long long> > G(n);
  vector<long double> V(n);
  vector<long long> deg(n);
  for (auto &x : V) cin >> x;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
    deg[a]++;
    deg[b]++;
  }
  if (n == 1) {
    int q;
    cin >> q;
    while (q--) {
      int a;
      long double p;
      cin >> a >> p;
      cout << (1 - p) << endl;
    }
    return 0;
  }
  long double res = 1;
  for (int i = 0; i < n; i++) res += V[i] * (G[i].size() - 1);
  vector<long double> neighp(n, 0.0);
  for (int i = 0; i < n; i++) {
    for (auto x : G[i]) {
      res -= 0.5 * V[i] * V[x];
      neighp[i] += V[x];
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int v;
    long double p;
    cin >> v >> p;
    long double deltap = p - V[v];
    res += (deg[v] - 1 - neighp[v]) * deltap;
    for (auto x : G[v]) {
      neighp[x] += deltap;
    }
    V[v] = p;
    cout << res << "\n";
  }
}
