#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 50;
double f[N], p[N], q[N];
int fa[N];
vector<int> a[N];
int n;
double ans;
void dfs(int x, int y) {
  fa[x] = y;
  for (auto i : a[x])
    if (i != y) {
      dfs(i, x);
      q[x] += 1 - p[i];
      f[x] += f[i] + (1 - p[i]) * (1 - q[i]);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x++;
    y++;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  dfs(1, 0);
  ans = f[1];
  int query;
  scanf("%d", &query);
  while (query--) {
    int pos;
    double newp;
    scanf("%d%lf", &pos, &newp);
    pos++;
    if (fa[fa[pos]] != 0) {
      ans -= (1 - p[fa[pos]]) * (1 - q[fa[pos]]);
      q[fa[pos]] += p[pos];
      q[fa[pos]] -= newp;
      ans += (1 - p[fa[pos]]) * (1 - q[fa[pos]]);
      ans -= (1 - p[pos]) * (1 - q[pos]);
      p[pos] = newp;
      ans += (1 - p[pos]) * (1 - q[pos]);
    } else if (fa[pos] != 0) {
      q[fa[pos]] += p[pos];
      q[fa[pos]] -= newp;
      ans -= (1 - p[pos]) * (1 - q[pos]);
      p[pos] = newp;
      ans += (1 - p[pos]) * (1 - q[pos]);
    } else {
      p[pos] = newp;
    }
    printf("%.7lf\n", ans + (1 - p[1]) * (-q[1] + 1));
  }
  return 0;
}
