#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool d = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') d = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return d ? x : -x;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar('0' + x % 10);
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
inline void writep(long long x) {
  write(x);
  putchar(' ');
}
inline unsigned long long rnd() {
  return ((unsigned long long)rand() << 30 ^ rand()) << 4 | rand() % 4;
}
const int N = 1e5 + 5;
int fa[N];
vector<long long> v[N];
double ans, a[N], sum[N];
void dfs(int u) {
  for (auto k : v[u]) {
    if (k == fa[u]) continue;
    sum[u] += 1.0 - a[k];
    fa[k] = u;
    dfs(k);
  }
  ans += a[u] * sum[u];
}
int main() {
  int n = read();
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%lf", &a[i]);
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    int x = read() + 1, y = read() + 1;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1);
  int m = read();
  while (m--) {
    int x = read() + 1;
    double y;
    scanf("%lf", &y);
    ans -= a[x] * sum[x];
    ans += y * sum[x];
    ans -= a[fa[x]] * sum[fa[x]];
    sum[fa[x]] = sum[fa[x]] - (1.0 - a[x]) + (1.0 - y);
    ans += a[fa[x]] * sum[fa[x]];
    a[x] = y;
    printf("%.5lf\n", ans + 1.0 - a[1]);
  }
}
