#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], toUpdate;
double res = 0.0;
int n;
void input_prepare() {
  cin >> n;
  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 main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  unordered_set<int>::iterator it;
  input_prepare();
  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.insert(v);
    if ((int)toUpdate.size() >= 100) {
      for (auto a : toUpdate) {
        for (auto b : edge[a]) {
          sumEdge[b] = sumEdge[b] - iniNode[a] + node[a];
        }
        iniNode[a] = node[a];
      }
      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;
}
