#include <bits/stdc++.h>
using namespace std;
int read_int() {
  char ch = getchar();
  int res = 0, k = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      k = -1;
    else
      k = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    res = (res << 1) + (res << 3) + ch - '0';
    ch = getchar();
  }
  return res * k;
}
int read_unsigned() {
  char ch = getchar();
  int res = 0;
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    res = (res << 1) + (res << 3) + ch - '0';
    ch = getchar();
  }
  return res;
}
int n, fa[100005];
double p[100005], sum[100005], ans;
vector<int> tree[100005];
inline void add(int a, int b) {
  tree[a].push_back(b);
  return;
}
void dfs(int root) {
  for (int i = 0; i < tree[root].size(); ++i) {
    int x = tree[root][i];
    if (x == fa[root]) continue;
    fa[x] = root;
    dfs(x);
    sum[root] += p[x];
  }
  ans += ((double)1 - p[fa[root]]) * p[root];
}
int main() {
  n = read_unsigned();
  for (int i = 1; i <= n; ++i) scanf("%lf", &p[i]), p[i] = (double)1 - p[i];
  for (int i = 1; i < n; ++i) {
    int a = read_unsigned() + 1, b = read_unsigned() + 1;
    add(a, b);
    add(b, a);
  }
  dfs(1);
  int q = read_unsigned();
  while (q--) {
    int x = read_unsigned() + 1;
    double g, h = p[x];
    scanf("%lf", &g);
    g = (double)1 - g;
    ans += (g - h) * ((double)1 - p[fa[x]]);
    ans += (h - g) * sum[x];
    sum[fa[x]] += g - h;
    p[x] = g;
    printf("%.15lf\n", ans);
  }
  return 0;
}
