#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const long long LINF = 2e16;
const int magic = 348;
const int MOD = 998244353;
const double eps = 1e-10;
const double pi = acos(-1);
struct fastio {
  static const int S = 1e7;
  char rbuf[S + 48], wbuf[S + 48];
  int rpos, wpos, len;
  fastio() { rpos = len = wpos = 0; }
  inline char Getchar() {
    if (rpos == len) rpos = 0, len = fread(rbuf, 1, S, stdin);
    if (!len) return EOF;
    return rbuf[rpos++];
  }
  template <class T>
  inline void Get(T &first) {
    char ch;
    bool f;
    T res;
    while (!isdigit(ch = Getchar()) && ch != '-') {
    }
    if (ch == '-')
      f = false, res = 0;
    else
      f = true, res = ch - '0';
    while (isdigit(ch = Getchar())) res = res * 10 + ch - '0';
    first = (f ? res : -res);
  }
  inline void getstring(char *s) {
    char ch;
    while ((ch = Getchar()) <= 32) {
    }
    for (; ch > 32; ch = Getchar()) *s++ = ch;
    *s = '\0';
  }
  inline void flush() {
    fwrite(wbuf, 1, wpos, stdout);
    fflush(stdout);
    wpos = 0;
  }
  inline void Writechar(char ch) {
    if (wpos == S) flush();
    wbuf[wpos++] = ch;
  }
  template <class T>
  inline void Print(T first, char ch) {
    char s[20];
    int pt = 0;
    if (first == 0)
      s[++pt] = '0';
    else {
      if (first < 0) Writechar('-'), first = -first;
      while (first) s[++pt] = '0' + first % 10, first /= 10;
    }
    while (pt) Writechar(s[pt--]);
    Writechar(ch);
  }
  inline void printstring(char *s) {
    int pt = 1;
    while (s[pt] != '\0') Writechar(s[pt++]);
  }
} io;
template <typename T>
inline void check_max(T &first, T cmp) {
  first = max(first, cmp);
}
template <typename T>
inline void check_min(T &first, T cmp) {
  first = min(first, cmp);
}
template <typename T>
inline T myabs(T first) {
  return first >= 0 ? first : -first;
}
const int MAXN = 1e5;
int n, q;
double p[MAXN + 48], dp[MAXN + 48], psum[MAXN + 48];
int fa[MAXN + 48];
vector<int> v[MAXN + 48];
inline void dfs(int cur, int father) {
  dp[cur] = psum[cur] = 0;
  fa[cur] = father;
  for (auto second : v[cur])
    if (second != father)
      dfs(second, cur), dp[cur] += dp[second],
          psum[cur] += double(1.0 - p[second]);
  dp[cur] -= double(1.0 - p[cur]) * (psum[cur] - 1);
}
int main() {
  scanf("%d", &n);
  int first, second;
  double nv;
  for (register int i = 1; i <= n; i++) scanf("%lf", &p[i]);
  for (register int i = 1; i <= n - 1; i++) {
    scanf("%d%d", &first, &second);
    first++;
    second++;
    v[first].push_back(second);
    v[second].push_back(first);
  }
  dfs(1, -1);
  scanf("%d", &q);
  double ans = dp[1];
  while (q--) {
    scanf("%d%lf", &first, &nv);
    first++;
    ans += double(1.0 - p[first]) * (psum[first] - 1);
    ans -= double(1.0 - nv) * (psum[first] - 1);
    if (first != 1) {
      int f = fa[first];
      ans += double(1.0 - p[f]) * (psum[f] - 1);
      psum[f] -= double(1.0 - p[first]);
      psum[f] += double(1.0 - nv);
      ans -= double(1.0 - p[f]) * (psum[f] - 1);
    }
    p[first] = nv;
    printf("%lf\n", ans);
  }
  return 0;
}
