#include <bits/stdc++.h>
using namespace std;
const int MAX = 100007;
long double pr[MAX];
long double sonsum[MAX];
vector<int> edg[MAX];
int parent[MAX];
void dfs(int u, int p = -1) {
  sonsum[u] = 0;
  for (int v : edg[u]) {
    if (v == p) continue;
    sonsum[u] += pr[v];
    parent[v] = u;
    dfs(v, u);
  }
}
long double ans;
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%Lf", &pr[i]);
  }
  for (int i = 1; i < N; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    edg[u].push_back(v);
    edg[v].push_back(u);
  }
  dfs(0);
  ans = 1;
  for (int i = 0; i < N; i++) {
    ans += pr[i] * ((long double)edg[i].size() - 1);
    ans -= pr[i] * sonsum[i];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int u;
    long double wut;
    scanf("%d %Lf", &u, &wut);
    long double del = wut - pr[u];
    ans += del * ((long double)edg[u].size() - 1);
    ans -= del * sonsum[u];
    pr[u] = wut;
    if (u > 0) {
      ans -= pr[parent[u]] * del;
      sonsum[parent[u]] += del;
    }
    printf("%.8Lf\n", ans);
  }
  return 0;
}
