#include <bits/stdc++.h>
using namespace std;
int n, m, fa[100010];
double sum[100010], a[100010], ans;
vector<int> v[100010];
void read(int& x) {
  char c = getchar();
  x = 0;
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
}
void dfs(int x) {
  for (int y : v[x]) {
    if (y == fa[x]) continue;
    fa[y] = x;
    sum[x] += (1.0 - a[y]);
    dfs(y);
  }
  ans += sum[x] * a[x];
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &a[i]);
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    read(x);
    read(y);
    x++;
    y++;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  a[0] = 1.0;
  v[0].push_back(1);
  dfs(0);
  read(m);
  for (int i = 1; i <= m; i++) {
    int x;
    read(x);
    x++;
    ans -= sum[fa[x]] * a[fa[x]];
    ans -= a[x] * sum[x];
    sum[fa[x]] -= (1.0 - a[x]);
    scanf("%lf", &a[x]);
    sum[fa[x]] += (1.0 - a[x]);
    ans += a[x] * sum[x];
    ans += sum[fa[x]] * a[fa[x]];
    printf("%.5lf\n", ans);
  }
}
