#include <bits/stdc++.h>
using namespace std;
int n, deg[100005];
int val[100005], ans[100005];
vector<int> a[100005], can[100005];
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    double p;
    scanf("%lf", &p);
    val[i] = p * 100 + 0.5;
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    a[u].emplace_back(v);
    a[v].emplace_back(u);
    deg[u]++;
    deg[v]++;
  }
  for (int i = 0; i < n; i++) {
    for (auto j : a[i]) {
      if (deg[j] >= 320) {
        can[i].emplace_back(j);
        ans[j] += val[i];
      }
    }
  }
  int sum1 = 0, sum2 = 0;
  for (int i = 0; i < n; i++) {
    sum1 += (deg[i] - 1) * val[i];
    for (auto j : a[i]) {
      sum2 += val[i] * val[j];
    }
  }
  sum2 /= 2;
  int q;
  scanf("%d", &q);
  while (q--) {
    int first;
    double _d;
    scanf("%d", &first);
    scanf("%lf", &_d);
    int d = _d * 100 + 0.5;
    if (deg[first] < 320) {
      for (auto i : a[first]) {
        sum2 += val[i] * (d - val[first]);
      }
    } else
      sum2 += ans[first] * (d - val[first]);
    for (auto i : can[first]) ans[i] += d - val[first];
    sum1 += (deg[first] - 1) * (d - val[first]);
    val[first] = d;
    printf("%0.6lf\n", (sum1 / 100.0 - sum2 / 10000.0 + 1));
  }
}
signed main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
