#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int v[N];
struct E {
  int t, next;
} e[N << 1];
int num;
void add(int s, int t) {
  e[++num] = (E){t, v[s]}, v[s] = num;
  e[++num] = (E){s, v[t]}, v[t] = num;
}
double p[N], s[N];
int f[N], c[N];
void dfs(int x) {
  for (int i = v[x]; i; i = e[i].next) {
    int ch = e[i].t;
    if (ch == f[x]) continue;
    f[ch] = x;
    dfs(ch);
    s[x] += p[ch];
    ++c[x];
  }
}
int n, q, st, ed, x;
double _p;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lf", &p[i]);
  for (int i = 1; i <= n - 1; ++i) {
    scanf("%d %d", &st, &ed);
    ++st, ++ed;
    add(st, ed);
  }
  dfs(1);
  p[0] = 1, s[0] = p[1], c[0] = 1;
  double ans = 0;
  for (int i = 0; i <= n; ++i) ans += p[i] * (c[i] - s[i]);
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    scanf("%d %lf", &x, &_p);
    ++x;
    ans -= p[f[x]] * (c[f[x]] - s[f[x]]);
    s[f[x]] += -p[x] + _p;
    ans += p[f[x]] * (c[f[x]] - s[f[x]]);
    ans -= p[x] * (c[x] - s[x]);
    p[x] = _p;
    ans += p[x] * (c[x] - s[x]);
    printf("%.5lf\n", ans);
  }
}
