#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using namespace std;
const int MAXN = 120000;
const int SQ = 300;
int n;
string s;
long double p[MAXN];
long double read() {
  cin >> s;
  return s[0] - '0' + 0.1 * (s[2] - '0') + 0.01 * (s[3] - '0');
}
vector<int> eds[MAXN];
int fl[MAXN];
long double cs[MAXN];
vector<int> eds2[MAXN];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(6);
  cin >> n;
  long double ans = 0;
  for (int i = 0; i < n; ++i) {
    p[i] = read();
    p[i] = 1 - p[i];
    ans += p[i];
  }
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    ans -= p[a] * p[b];
    eds[a].push_back(b);
    eds[b].push_back(a);
    cs[a] += p[b];
    cs[b] += p[a];
  }
  for (int i = 0; i < n; ++i)
    if (eds[i].size() > SQ) fl[i] = 1;
  for (int i = 0; i < n; ++i) {
    for (int x : eds[i])
      if (fl[x]) eds2[i].push_back(x);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int x;
    cin >> x;
    long double np = 1 - read();
    ans += np - p[x];
    if (fl[x]) {
      ans -= (np - p[x]) * cs[x];
    } else {
      for (int y : eds[x]) ans -= (np - p[x]) * p[y];
    }
    for (int y : eds2[x]) cs[y] += (np - p[x]);
    p[x] = np;
    cout << ans << "\n";
  }
  return 0;
}
