#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
vector<int> adj[N];
int par[N];
double ar[N], f[N];
void dfs(int x, int p) {
  for (int i = 0; i < adj[x].size(); i++) {
    if (adj[x][i] != p) {
      f[x] += ar[adj[x][i]];
      par[adj[x][i]] = x;
      dfs(adj[x][i], x);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, i, j, k, l, q;
  double ev = 0, cac;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> ar[i];
    ar[i] = 1 - ar[i];
    ev += ar[i];
  }
  for (i = 1; i < n; i++) {
    cin >> j >> k;
    j++;
    k++;
    adj[j].push_back(k);
    adj[k].push_back(j);
  }
  dfs(1, 1);
  for (i = 1; i <= n; i++) {
    ev -= ar[i] * f[i];
  }
  cin >> q;
  for (i = 1; i <= q; i++) {
    cin >> j >> cac;
    cac = 1 - cac;
    j++;
    ev += ar[j] * f[j];
    ev += ar[par[j]] * f[par[j]];
    ev -= ar[j];
    f[par[j]] -= ar[j];
    ar[j] = cac;
    f[par[j]] += ar[j];
    ev -= ar[j] * f[j];
    ev -= ar[par[j]] * f[par[j]];
    ev += ar[j];
    cout << fixed << setprecision(6) << ev << "\n";
  }
}
