#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, x, y, q, o[N];
double p[N], c[N], z, fp;
vector<int> v[N];
void sgd(int dg, int op) {
  o[dg] = op;
  for (int i = 0; i < v[dg].size(); ++i) {
    if (v[dg][i] != op) {
      sgd(v[dg][i], dg);
      c[dg] += p[v[dg][i]];
    }
  }
  fp -= p[dg] * c[dg];
}
void G(int x, double y) {
  y = 1.0 - y;
  c[o[x]] += y - p[x];
  fp += (1.0 - c[x] - p[o[x]]) * (y - p[x]);
  p[x] = y;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    p[i] = 1.0 - p[i];
    fp += p[i];
  }
  for (int i = 1; i < n; ++i) {
    cin >> x >> y;
    v[x + 1].push_back(y + 1);
    v[y + 1].push_back(x + 1);
  }
  sgd(1, 0);
  cin >> q;
  for (int i = 1; i <= q; ++i) {
    cin >> x >> z;
    G(x + 1, z);
    cout << setprecision(5) << fp << "\n";
  }
  return 0;
}
