#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int N = 100005;
double sumEdge[N], node[N], iniNode[N];
unordered_set<int> edge[N];
vector<int> toUpdate;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  unordered_set<int>::iterator it;
  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];
    iniNode[i] = node[i];
  }
  for (int i = 1; i <= n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    edge[x].insert(y);
    edge[y].insert(x);
    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];
    node[v] = val;
    toUpdate.push_back(v);
    if ((int)toUpdate.size() > 316) {
      fill(sumEdge, sumEdge + n, 0.0);
      for (int x = 0; x <= n - 1; ++x) {
        for (it = edge[x].begin(); it != edge[x].end(); it++) {
          sumEdge[x] += node[*it];
        }
      }
      for (int i = 0; i <= n - 1; ++i) {
        iniNode[i] = node[i];
      }
      toUpdate.clear();
    }
    double temp = sumEdge[v];
    for (int a : toUpdate) {
      if (edge[v].find(a) != edge[v].end()) {
        temp = temp + (-iniNode[a] + node[a]);
      }
    }
    res = res + delta - temp * delta;
    cout << fixed << setprecision(9) << res << '\n';
  }
  return 0;
}
