#include <bits/stdc++.h>
using namespace std;
double p[100005], cnt[100005], f[100005];
vector<int> e[100005];
int fa[100005];
void dfs(int x, int fa) {
  double sum = 0;
  ::fa[x] = fa;
  for (auto &v : e[x])
    if (v != fa) {
      dfs(v, x);
      sum += f[v];
      cnt[x] += p[v];
    }
  f[x] = sum + p[x] * (1 - cnt[x]);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lf", &p[i]);
    p[i] = 1 - p[i];
  }
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    e[a].push_back(b);
    e[b].push_back(a);
  }
  dfs(0, -1);
  int q;
  cin >> q;
  while (q--) {
    int a;
    double b;
    scanf("%d%lf", &a, &b);
    b = 1 - b;
    printf("%.10f\n",
           f[0] += (1 - cnt[a]) * (b - p[a]) - (a ? p[fa[a]] * (b - p[a]) : 0));
    if (a) cnt[fa[a]] += b - p[a];
    p[a] = b;
  }
  return 0;
}
