#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long n, q;
vector<long long> g[100010];
long double a[100010], b[100010], c[100010];
long long p[100010];
void dfs(long long u, long long pa = -1) {
  for (auto v : g[u]) {
    if (v == pa) continue;
    p[v] = u, b[u] += a[v];
    dfs(v, u);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  long double tot = 0, T = 0;
  for (long long i = 1; i < n + 1; ++i)
    cin >> a[i], a[i] = 1.0 - a[i], tot += a[i];
  for (long long i = 0; i < n - 1; ++i) {
    long long u, v;
    cin >> u >> v;
    ++u, ++v;
    g[u].push_back(v), g[v].push_back(u);
  }
  p[1] = 0;
  dfs(1);
  for (long long i = 1; i < n + 1; ++i) T += a[i] * b[i];
  cin >> q;
  for (long long i = 0; i < q; ++i) {
    long long u;
    cin >> u;
    ++u;
    long double pr;
    cin >> pr;
    pr = 1.0 - pr;
    tot += (pr - a[u]),
        T += (pr * b[u] + pr * a[p[u]]) - (a[u] * b[u] + a[u] * a[p[u]]);
    b[p[u]] += (pr - a[u]), a[u] = pr;
    cout << setprecision(10) << tot - T << "\n";
  }
  return 0;
}
