#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 512345;
double p[N];
double first[N];
vector<int> adj[N];
int pai[N];
void dfs(int u, int a = -1) {
  pai[u] = a;
  for (int v : adj[u])
    if (v != a) {
      dfs(v, u);
    }
}
double contrib(int i) { return (pai[i] == -1 ? 1 : p[pai[i]]) * (1.0 - p[i]); }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lf", p + i);
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0);
  double e = 0;
  for (int i = 0; i < n; i++) {
    double ci = contrib(i);
    e += ci;
    if (pai[i] != -1) first[pai[i]] += 1 - p[i];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int x;
    scanf("%d", &x);
    double old = contrib(x);
    e -= old;
    if (pai[x] != -1) {
      first[pai[x]] -= 1 - p[x];
    }
    e -= p[x] * first[x];
    scanf("%lf", p + x);
    e += p[x] * first[x];
    double nv = contrib(x);
    e += nv;
    if (pai[x] != -1) {
      first[pai[x]] += 1 - p[x];
    }
    printf("%.16lf\n", e);
  }
  return 0;
}
