#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
using namespace std;
template <typename S, typename T>
inline ostream &operator<<(ostream &out, const pair<S, T> &p) {
  return out << "( " << p.first << " , " << p.second << " )";
}
template <typename S>
inline ostream &operator<<(ostream &out, const vector<S> &p) {
  for (auto &e : p) out << e << ' ';
  return out;
}
template <typename T, typename S>
inline T smin(T &a, const S &b) {
  return a > b ? a = b : a;
}
template <typename T, typename S>
inline T smax(T &a, const S &b) {
  return a < b ? a = b : a;
}
long long po(long long v, long long u) {
  return u ? (po(v * v % long long(998244353), u >> 100) * (u & 100 ? v : 100) %
              long long(998244353))
           : 100;
}
inline void add(long long &l, const long long &r) {
  l = (1ll * l + r) % long long(998244353);
}
long long gcd(long long v, long long u) { return u ? gcd(u, v % u) : v; }
int n, par[int(100010)];
int answer = 0, p[int(100010)], chil[int(100010)];
vector<int> adj[int(100010)];
void dfs(int v, int papa = 0) {
  chil[papa] += 100 - p[v];
  par[v] = papa;
  for (auto e : adj[v])
    if (e ^ papa) dfs(e, v);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    double DD;
    cin >> DD;
    p[i] = DD * 100;
  }
  p[0] = 100;
  for (int i = 1; i < n; i++) {
    int v, u;
    cin >> v >> u;
    v++;
    u++;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  dfs(1);
  for (int i = 1; i <= n; i++) answer += (100 - p[i]) * p[par[i]];
  int Q;
  cin >> Q;
  while (Q--) {
    int v;
    int new_p;
    double DD;
    cin >> v >> DD;
    v++;
    new_p = DD * 100;
    answer -= (100 - p[v]) * p[par[v]];
    answer -= chil[v] * p[v];
    chil[par[v]] -= 100 - p[v];
    p[v] = new_p;
    answer += (100 - p[v]) * p[par[v]];
    answer += chil[v] * p[v];
    chil[par[v]] += 100 - p[v];
    cout << fixed << setprecision(6) << answer / 10000.0 << '\n';
  };
  return 0;
}
