import java.util.*;
import java.math.*;
import java.io.*;

public class CF1045D {
	class Tree {
		int n, p[];
		List<Integer>[] adj;
		public Tree(int nn) {
			adj = new ArrayList[n = nn];
			for(int i = 0 ; i < n ; i++)
				adj[i] = new ArrayList<>();
			p = new int[n];
			Arrays.fill(p, -1);
		}
		void add(int u, int v) {
			adj[u].add(v);
			adj[v].add(u);
		}
		void root() {
			Deque<Integer> q = new ArrayDeque<>();
			q.add(0);
			while(!q.isEmpty()) {
				int u = q.pop();
				for(int v : adj[u]) {
					if(p[u] != v) {
						p[v] = u;
						q.add(v);
					}
				}
			}
		}
	}
	public CF1045D() {
		FS scan = new FS();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		double[] prob = new double[n];
		for(int i = 0 ; i < n ; i++)
			prob[i] = scan.nextDouble();
		Tree G = new Tree(n);
		for(int i = 0 ; i < n - 1 ; i++) {
			int u = scan.nextInt(), v = scan.nextInt();
			G.add(u, v);
		}
		G.root();
		double[] childsum = new double[n];
		for(int u = 0 ; u < n ; u++)
			for(int v : G.adj[u])
				if(G.p[u] != v)
					childsum[u] += (1 - prob[v]);
		double res = 1 - prob[0];
		for(int i = 0 ; i < n ; i++)
			res += childsum[i] * prob[i];
		int q = scan.nextInt();
		for(int qq = 0 ; qq < q ; qq++) {
			int node = scan.nextInt();
			double newprob = scan.nextDouble();
			if(G.p[node] != -1) {
				res -= childsum[G.p[node]] * prob[G.p[node]];
				childsum[G.p[node]] -= (1 - prob[node]);
				childsum[G.p[node]] += (1 - newprob);
				res += childsum[G.p[node]] * prob[G.p[node]];
			} else {
				res -= (1 - prob[0]);
				res += (1 - newprob);
			}
			res -= childsum[node] * prob[node];
			prob[node] = newprob;
			res += childsum[node] * prob[node];
			out.println(res);
		}
		out.close();
	}
	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() {
			while(!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch(Exception e) { e.printStackTrace(); }
			}
			return st.nextToken();
		}
		public int nextInt() { return Integer.parseInt(next()); }
		public double nextDouble() { return Double.parseDouble(next()); }
	}
	public static void main(String[] args) { new CF1045D(); }
}
