#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
double p[N];
vector<int> v[N];
double sum[N];
int d[N];
int eu[N];
int ev[N];
int n;
double ans;
int q;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lf", &p[i]), p[i] = 1 - p[i], ans += p[i];
  for (int i = 1; i < n; i++)
    scanf("%d%d", &eu[i], &ev[i]), d[eu[i]]++, d[ev[i]]++;
  for (int i = 1; i < n; i++)
    if (d[eu[i]] < d[ev[i]])
      v[eu[i]].push_back(ev[i]), sum[ev[i]] += p[eu[i]];
    else
      v[ev[i]].push_back(eu[i]), sum[eu[i]] += p[ev[i]];
  for (int i = 1; i < n; i++) ans -= p[eu[i]] * p[ev[i]];
  scanf("%d", &q);
  vector<int>::iterator it;
  for (int i = 1, u; i <= q; i++) {
    double del = 0;
    scanf("%d", &u);
    del = sum[u];
    for (it = v[u].begin(); it != v[u].end(); ++it) {
      del += p[*it];
      sum[*it] -= p[u];
    }
    ans += p[u] * del;
    ans -= p[u];
    scanf("%lf", &p[u]);
    p[u] = 1 - p[u];
    ans -= p[u] * del;
    ans += p[u];
    for (it = v[u].begin(); it != v[u].end(); ++it) sum[*it] += p[u];
    printf("%lf\n", ans);
  }
  srand(time(0));
  int hhh = rand();
  if (hhh % 4 == 1 || hhh % 5 == 2) printf("dgh");
  return 0;
}
