#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void print(int x) {
  write(x);
  printf(" ");
}
struct node {
  int x, y, next;
} a[210000];
int len, last[110000];
void ins(int x, int y) {
  len++;
  a[len].x = x;
  a[len].y = y;
  a[len].next = last[x];
  last[x] = len;
}
queue<int> li;
int fa[110000];
void pre_tree_node(int x) {
  for (int k = last[x]; k; k = a[k].next)
    if (a[k].y != fa[x]) fa[a[k].y] = x, pre_tree_node(a[k].y);
}
int in[110000], ot[110000], deg[110000], bfn;
int fir[110000];
void init_BFS() {
  li.push(1);
  in[1] = ++bfn;
  while (!li.empty()) {
    int x = li.front();
    fir[x] = bfn;
    for (int k = last[x]; k; k = a[k].next)
      if (a[k].y != fa[x]) {
        int y = a[k].y;
        in[y] = ++bfn;
        li.push(y);
      }
    li.pop();
    ot[x] = bfn;
  }
}
double s[110000];
int n, T;
int lowbit(int x) { return x & -x; }
void change(int x, double c) {
  for (int i = x; i <= n; i += lowbit(i)) s[i] += c;
}
double findsum(int x) {
  double ret = 0;
  for (int i = x; i >= 1; i -= lowbit(i)) ret += s[i];
  return ret;
}
double cal[110000];
int main() {
  n = read();
  for (int i = 1; i <= n; i++) scanf("%lf", &cal[i]), cal[i] = 1.0 - cal[i];
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    x++;
    y++;
    ins(x, y);
    ins(y, x);
  }
  pre_tree_node(1);
  init_BFS();
  for (int i = 1; i <= n; i++) change(in[i], cal[i]);
  T = read();
  double s1 = 0, s2 = 0;
  for (int i = 1; i <= n; i++) s1 += cal[i];
  for (int i = 1; i <= n; i++) {
    double S = findsum(ot[i]) - findsum(fir[i]);
    s2 += cal[i] * S;
  }
  while (T--) {
    int x = read();
    double c;
    scanf("%lf", &c);
    c = 1 - c;
    x++;
    s1 -= cal[x];
    s1 += c;
    double S = findsum(ot[x]) - findsum(fir[x]);
    s2 -= cal[x] * S;
    s2 += c * S;
    s2 -= cal[x] * cal[fa[x]];
    s2 += c * cal[fa[x]];
    change(in[x], -cal[x] + c);
    cal[x] = c;
    printf("%.5lf\n", s1 - s2);
  }
  return 0;
}
