#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int N = 100005;
double sumEdge[N], node[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  double res = 0.0;
  for (int i = 0; i <= n - 1; ++i) {
    double x;
    cin >> x;
    node[i] = 1.0 - x;
    res += node[i];
  }
  for (int i = 1; i <= n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    sumEdge[x] += node[y];
    sumEdge[y] += node[x];
  }
  for (int i = 0; i <= n - 1; ++i) {
    res -= (sumEdge[i] * node[i]) / 2;
  }
  int q;
  cin >> q;
  while (q--) {
    int v;
    double val;
    cin >> v >> val;
    val = 1.0 - val;
    double delta = val - node[v];
    res = res + delta - sumEdge[v] * delta;
    cout << fixed << setprecision(9) << res << '\n';
  }
  return 0;
}
