#include <bits/stdc++.h>
using namespace std;
int n, i, x, y, q, fat[100010];
long double nw, a0, p[100010], aux[100010];
vector<int> v[100010];
bool viz[100010];
void dfs(int poz) {
  for (auto it : v[poz])
    if (it != fat[poz]) {
      fat[it] = poz;
      dfs(it);
    }
  aux[poz] = 1;
  for (auto it : v[poz])
    if (it != fat[poz]) aux[poz] += p[it] - 1;
  if (poz != 1) a0 += aux[poz] * (1 - p[poz]);
}
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> p[i];
  for (i = 1; i < n; i++) {
    cin >> x >> y;
    x++, y++;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  cin >> q;
  a0 = 0;
  dfs(1);
  for (; q; q--) {
    cin >> x >> nw;
    x++;
    if (x != 1) {
      a0 -= aux[x] * (1 - p[x]);
      a0 -= aux[fat[x]] * (1 - p[fat[x]]);
      aux[fat[x]] += nw - p[x];
      p[x] = nw;
      a0 += aux[x] * (1 - p[x]);
      a0 += aux[fat[x]] * (1 - p[fat[x]]);
    } else
      p[x] = nw;
    cout << fixed << setprecision(10) << a0 + aux[1] - p[1] * aux[1] << '\n';
  }
  return 0;
}
