#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
int n, m, i, j, x, y, fa[100005];
double s, a[100005], z, sum[100005];
vector<int> e[100005];
void dfs(int x, int p) {
  fa[x] = p;
  for (__typeof((e[x]).begin()) itcalc = (e[x]).begin(); itcalc != (e[x]).end();
       itcalc++)
    if (*itcalc != p) dfs(*itcalc, x);
}
int main() {
  scanf("%d", &n);
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) scanf("%lf", &a[i]);
  for (((i)) = (1); ((i)) <= ((n - 1)); ((i))++) {
    scanf("%d%d", &x, &y);
    x++;
    y++;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1, 0);
  scanf("%d", &m);
  a[0] = 1;
  s = 0;
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    s += a[fa[i]] * (1 - a[i]);
    sum[fa[i]] += 1 - a[i];
  }
  while (m--) {
    scanf("%d%lf", &x, &z);
    x++;
    s -= a[fa[x]] * (1 - a[x]);
    s -= sum[x] * a[x];
    sum[fa[x]] -= 1 - a[x];
    a[x] = z;
    sum[fa[x]] += 1 - a[x];
    s += a[fa[x]] * (1 - a[x]);
    s += sum[x] * a[x];
    printf("%.10f\n", s);
  }
  return 0;
}
