#include <bits/stdc++.h>
using namespace std;
double p[100005], f[100005];
int pa[100005];
vector<int> v[100005];
void DFS(int now, int fa) {
  pa[now] = fa;
  for (int i : v[now]) {
    if (i != fa) {
      f[now] += p[i];
      DFS(i, now);
    }
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i], p[i] = 1 - p[i];
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  double ans = 0;
  DFS(0, -1);
  for (int i = 0; i < n; i++) ans += p[i];
  for (int i = 0; i < n; i++) ans -= p[i] * f[i];
  int m;
  cin >> m;
  while (m--) {
    int wh;
    double ch;
    cin >> wh >> ch;
    ch = 1 - ch;
    ans -= p[wh];
    ans += p[wh] * f[wh];
    if (wh != 0) {
      ans += p[pa[wh]] * f[pa[wh]];
      f[pa[wh]] -= p[wh];
    }
    p[wh] = ch;
    ans += p[wh];
    ans -= p[wh] * f[wh];
    if (wh != 0) {
      f[pa[wh]] += p[wh];
      ans -= p[pa[wh]] * f[pa[wh]];
    }
    cout << fixed << setprecision(15) << ans << '\n';
  }
  return 0;
}
