#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
mt19937_64 mt_rand(chrono::system_clock::now().time_since_epoch().count());
template <typename T1, typename T2>
inline bool upmax(T1& a, T2 b) {
  return (a < b ? (a = b, true) : false);
}
template <typename T1, typename T2>
inline bool upmin(T1& a, T2 b) {
  return (b < a ? (a = b, true) : false);
}
const int maxn = (int)1e5 + 20;
const int maxlog = 21;
const int base = (int)1e9 + 7;
const long double eps = (long double)1e-7;
const long double PI = acos(-1.);
const int pp = 41;
double p[maxn];
vector<int> g[maxn];
long double f[maxn][2];
int n;
int pre[maxn];
double sump[maxn];
void dfs(int v, int pred = -1) {
  pre[v] = pred;
  for (int to : g[v]) {
    if (to == pred) continue;
    dfs(to, v);
    sump[v] += p[to];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lf", p + i);
  }
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  double ans = 1;
  for (int i = 0; i < n; i++) {
    ans += 1. * p[i] * ((int)g[i].size() - 1);
    for (int j : g[i]) {
      if (i < j) ans -= 1. * p[i] * p[j];
    }
  }
  dfs(0);
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int u;
    double x;
    scanf("%d %lf", &u, &x);
    ans -= p[u] * ((int)g[u].size() - 1);
    ans += x * ((int)g[u].size() - 1);
    ans += p[u] * (sump[u] + (u == 0 ? 0. : p[pre[u]]));
    ans -= x * (sump[u] + (u == 0 ? 0. : p[pre[u]]));
    if (u != 0) {
      sump[pre[u]] -= p[u];
      sump[pre[u]] += x;
    }
    p[u] = x;
    printf("%6lf\n", ans);
  }
  return 0;
}
