#include <bits/stdc++.h>
using namespace std;
int n, m, tot, x, y, f[200000], id[200000];
double ans, z, a[200000], s[200000];
vector<int> p[200000];
void dfs(int x) {
  ans += a[f[x]] * (1 - a[x]);
  for (auto i = p[x].begin(); i != p[x].end(); i++)
    if (*i == f[x]) {
      p[x].erase(i);
      break;
    }
  for (auto i : p[x])
    if (i != f[x]) {
      f[i] = x;
      id[i] = ++tot;
    }
  for (auto i : p[x])
    if (i != f[x]) dfs(i);
}
void fx(int x, double y) {
  for (; x < 200000; x += x & (-x)) s[x] += y;
}
double q(int x) {
  double y = 0;
  for (; x; x -= x & (-x)) y += s[x];
  return y;
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%lf", &a[i]);
  for (int i = (1); i <= (n - 1); i++) {
    scanf("%d%d", &x, &y);
    x++;
    y++;
    p[x].push_back(y);
    p[y].push_back(x);
  }
  a[0] = 1;
  tot = id[1] = 1;
  dfs(1);
  for (int i = (1); i <= (n); i++) fx(id[i], 1 - a[i]);
  for (scanf("%d", &m); m; m--) {
    scanf("%d%lf", &x, &z);
    x++;
    ans += a[f[x]] * (a[x] - z);
    fx(id[x], a[x] - z);
    if (p[x].size())
      ans += (z - a[x]) * (q(id[*(--p[x].end())]) - q(id[*p[x].begin()] - 1));
    a[x] = z;
    printf("%.5lf\n", ans);
  }
}
