#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <class T>
ostream& prnt(ostream& out, T v) {
  out << v.size() << '\n';
  for (auto e : v) out << e << ' ';
  return out;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> v) {
  return prnt(out, v);
}
template <class T>
ostream& operator<<(ostream& out, set<T> v) {
  return prnt(out, v);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, map<T1, T2> v) {
  return prnt(out, v);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  return out << '(' << p.first << ' ' << p.second << ')';
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
const long double PI = acos(-1);
int n, x, y, q, f[500005];
long double p[500005], dp[500005], s, val, s2;
vector<int> v[500005];
void dfs(int nod, int ant = -1) {
  s += p[nod];
  f[nod] = ant;
  for (auto it : v[nod]) {
    if (it == ant) continue;
    dp[nod] += p[it];
    dfs(it, nod);
  }
}
int main() {
  ios::sync_with_stdio(false);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%Lf", &p[i]), p[i] = 1 - p[i];
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(0);
  for (int i = 0; i < n; i++) s2 += dp[i] * p[i];
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%Lf", &x, &val);
    val = 1 - val;
    long double dif = val - p[x];
    s += dif;
    s2 -= dp[x] * p[x];
    p[x] = val;
    s2 += dp[x] * p[x];
    if (f[x] != -1) {
      s2 -= dp[f[x]] * p[f[x]];
      dp[f[x]] += dif;
      s2 += dp[f[x]] * p[f[x]];
    }
    cout << fixed << setprecision(9) << s - s2 << '\n';
  }
  return 0;
}
