#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;
int n, q, S;
int a[MAXN];
vector<int> e[MAXN], be[MAXN];
int deg[MAXN];
int bs[MAXN];
int qa, qb;
void init();
void input();
void inputq();
void work();
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d", &n);
  double tb;
  for (int i = 1; i <= n; ++i)
    scanf("%lf", &tb), a[i] = 100 - static_cast<int>(floor(tb * 100 + 0.5));
  int u, v;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    ++u, ++v;
    e[u].push_back(v);
    e[v].push_back(u);
    ++deg[u], ++deg[v];
  }
  scanf("%d", &q);
}
void inputq() {
  double tb;
  scanf("%d %lf", &qa, &tb);
  qb = static_cast<int>(floor(tb * 100 + 0.5));
}
void work() {
  int sv = 0, se = 0;
  for (int i = 1; i <= n; ++i) sv += a[i];
  for (int i = 1; i <= n; ++i)
    for (auto v : e[i])
      if (i < v) se += a[i] * a[v];
  S = static_cast<int>(ceil(sqrt(static_cast<long double>(n))));
  for (int i = 1; i <= n; ++i) {
    if (deg[i] >= S) {
      for (auto v : e[i]) bs[i] += a[v];
    }
  }
  for (int i = 1; i <= n; ++i)
    for (auto v : e[i])
      if (deg[v] >= S) be[i].push_back(v);
  int ns, del, ans;
  for (int _q = 0; _q < q; ++_q) {
    inputq();
    ++qa;
    qb = 100 - qb;
    del = qb - a[qa];
    if (deg[qa] < S) {
      ns = 0;
      for (auto v : e[qa]) ns += a[v];
      sv += del;
      se += del * ns;
    } else {
      sv += del;
      se += del * bs[qa];
    }
    for (auto v : be[qa]) bs[v] += del;
    a[qa] = qb;
    ans = sv * 100 - se;
    printf("%d.%04d\n", ans / 10000, ans % 10000);
  }
}
