#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double eps = (double)1e-9;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 100500, bl = 300;
long double ver, reb;
long double p[N], second[N];
vector<int> g[N], bg[N];
int n, q;
bool big[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    double x;
    scanf("%lf", &x);
    p[i] = 1 - x;
    ver += p[i];
  }
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    reb += p[x] * p[y];
    g[x].push_back(y);
    g[y].push_back(x);
  }
  scanf("%d", &q);
  for (int i = 0; i < n; i++) {
    if (int(g[i].size()) >= bl) big[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    for (int to : g[i]) {
      if (big[to]) {
        bg[i].push_back(to);
      } else
        second[i] += p[to];
    }
  }
  for (int i = 1; i <= q; i++) {
    int v;
    double x;
    scanf("%d %lf", &v, &x);
    ver -= p[v];
    reb -= second[v] * p[v];
    for (int to : bg[v]) {
      reb -= p[v] * p[to];
    }
    if (!big[v]) {
      for (int to : g[v]) {
        second[to] -= p[v];
      }
    }
    p[v] = 1 - x;
    ver += p[v];
    reb += second[v] * p[v];
    for (int to : bg[v]) {
      reb += p[v] * p[to];
    }
    if (!big[v]) {
      for (int to : g[v]) {
        second[to] += p[v];
      }
    }
    printf("%.12f\n", (double)(ver - reb));
  }
  return 0;
}
