#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T alex(T x) {
  return (x > 0) ? x : -x;
}
template <class T>
void read(T& x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while ((ch < 48 || ch > 57) && ch != 45) ch = getchar();
  if (ch == 45) f = -1, ch = getchar();
  while (ch >= 48 && ch <= 57) x = x * 10 + ch - 48, ch = getchar();
  x *= f;
}
int n;
double a[100005];
vector<int> E[100005];
int x[100005], y[100005];
double solve() {
  double res = 0.0;
  for (int i = (0); i < (n); i++) res += a[i];
  for (int i = (1); i < (n); i++) res -= a[x[i]] * a[y[i]];
  return res;
}
struct Tree {
  int l, r;
  double v;
} T[100005 << 2];
void build(int rot, int l, int r) {
  T[rot].l = l;
  T[rot].r = r;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(rot << 1, l, mid);
  build(rot << 1 | 1, mid + 1, r);
}
void update(int rot) { T[rot].v = T[rot << 1].v + T[rot << 1 | 1].v; }
void change(int rot, int pos, double v) {
  if (T[rot].l == T[rot].r) {
    T[rot].v = v;
    return;
  }
  int mid = (T[rot].l + T[rot].r) >> 1;
  if (pos <= mid)
    change(rot << 1, pos, v);
  else
    change(rot << 1 | 1, pos, v);
  update(rot);
}
double query(int rot, int l, int r) {
  if (l > r) return 0;
  if (T[rot].l == l && T[rot].r == r) return T[rot].v;
  int mid = (T[rot].l + T[rot].r) >> 1;
  if (r <= mid)
    return query(rot << 1, l, r);
  else if (l > mid)
    return query(rot << 1 | 1, l, r);
  else
    return query(rot << 1, l, mid) + query(rot << 1 | 1, mid + 1, r);
}
int que[100005], f[100005];
bool vis[100005];
int l[100005], r[100005];
int ind[100005];
void bfs() {
  que[1] = 1;
  vis[1] = true;
  ind[1] = 1;
  int head = 0, tail = 1;
  while (head != tail) {
    head++;
    int x = que[head];
    l[x] = tail + 1;
    for (int i = (0); i < (E[x].size()); i++)
      if (!vis[E[x][i]]) {
        f[E[x][i]] = x;
        que[++tail] = E[x][i];
        vis[E[x][i]] = true;
        ind[E[x][i]] = tail;
      }
    r[x] = tail;
  }
}
double get(int x) {
  if (x == 1)
    return query(1, l[x], r[x]);
  else
    return query(1, l[x], r[x]) + a[f[x]];
}
int main() {
  read(n);
  for (int i = (0); i < (n); i++) scanf("%lf", &a[i]), a[i] = 1.0 - a[i];
  for (int i = (1); i < (n); i++) {
    read(x[i]), read(y[i]);
    E[x[i]].push_back(y[i]);
    E[y[i]].push_back(x[i]);
  }
  int q;
  read(q);
  double res = solve();
  build(1, 1, n);
  bfs();
  for (int i = (1); i <= (n); i++) change(1, ind[i], a[i]);
  for (int i = (1); i <= (q); i++) {
    int x;
    double p;
    read(x);
    scanf("%lf", &p);
    res -= a[x];
    res += a[x] * get(x);
    a[x] = 1.0 - p;
    res += a[x];
    res -= a[x] * get(x);
    change(1, ind[x], a[x]);
    printf("%lf\n", res);
  }
  return 0;
}
