#include <bits/stdc++.h>
using namespace std;
const int max_n = 100111, inf = 1000111222;
const int sz = 300;
vector<int> v[max_n];
int n;
double p[max_n];
vector<pair<int, int>> check[max_n];
vector<pair<int, double>> qr;
bool res[max_n * sz];
void ans_all_qr() {
  for (int i = 0; i < n; ++i) {
    sort(v[i].begin(), v[i].end());
    sort(check[i].begin(), check[i].end());
    int pt = 0;
    for (int j = 0; j < check[i].size(); ++j) {
      int qind = check[i][j].second;
      int to = check[i][j].first;
      while (pt < v[i].size() && v[i][pt] < to) {
        ++pt;
      }
      if (pt == v[i].size() || v[i][pt] > to) {
        res[qind] = 0;
      } else {
        res[qind] = 1;
      }
    }
  }
}
double sum_to[max_n];
double cv = 0, ce = 0;
double pr[max_n];
double rp[max_n];
void rebuild() {
  cv = ce = 0;
  for (int i = 0; i < n; ++i) {
    cv += p[i];
    sum_to[i] = 0;
    for (int to : v[i]) {
      sum_to[i] += p[to];
    }
    ce += sum_to[i] * p[i];
    rp[i] = pr[i] = p[i];
  }
}
void upd_v(int cur, int to) { sum_to[cur]; }
int have[max_n];
int P[max_n];
void dfs(int cur, int pp) {
  P[cur] = pp;
  for (int to : v[cur]) {
    if (to != pp) {
      dfs(to, cur);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lf", p + i);
    p[i] = 1 - p[i];
  }
  for (int i = 0; i + 1 < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(0, -1);
  int q;
  scanf("%d", &q);
  int qind = 0;
  for (int i = 0; i < q; ++i) {
    int ver;
    double np;
    scanf("%d%lf", &ver, &np);
    np = 1 - np;
    qr.push_back(make_pair(ver, np));
  }
  qind = 0;
  int V = 0;
  for (int i = 0; i < q; ++i) {
    if (i % sz == 0) {
      rebuild();
    }
    int ver = qr[i].first;
    double np = qr[i].second;
    double st = sum_to[ver];
    ++V;
    for (int j = i - 1; j >= max(0, i - sz); --j) {
      int to = qr[j].first;
      if (j / sz == i / sz && (P[ver] == to || P[to] == ver) && have[to] != V) {
        have[to] = V;
        st -= pr[to];
        st += p[to];
      }
    }
    cv -= p[ver];
    ce -= st * p[ver] * 2;
    p[ver] = np;
    cv += p[ver];
    ce += st * p[ver] * 2;
    printf("%.10f\n", cv - ce / 2);
  }
  return 0;
}
