import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class d {

	/* @formatoff

12
0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5
0 6
0 7
6 2
7 3
7 10
7 11
2 8
2 1
2 5
11 9O
11 4


	 * @formaton
	 */
	static class Solver {

		int N, Q, par[], map[], l[], r[];
		double plive[], pfall[], iprob[], EXP_NODES, EXP_EDGES;
		ArrayList<Integer>[] adj;
		Node st;

		void rootDFS(int n, int p) {
			// ORIGINAL NUMBERING
			par[n] = p;
			adj[n].removeIf(x -> x == p);
			for (int i : adj[n])
				rootDFS(i, n);
		}

		@SuppressWarnings("unchecked")
		void solve(FastScanner s, PrintWriter out) {
			N = s.nextInt();
			iprob = new double[N];
			for (int i = 0; i < N; i++)
				iprob[i] = s.nextDouble();
			adj = new ArrayList[N];
			for (int i = 0; i < N; i++)
				adj[i] = new ArrayList<>();
			EXP_EDGES = 0;
			for (int i = 1; i < N; i++) {
				int u = s.nextInt(), v = s.nextInt();
				EXP_EDGES += (1 - iprob[u]) * (1 - iprob[v]);
				adj[u].add(v);
				adj[v].add(u);
			}
			par = new int[N];
			rootDFS(0, -1);
			// numbering
			map = new int[N];
			int ind = 0, cur;
			ArrayDeque<Integer> q = new ArrayDeque<>();
			q.add(0);
			while (!q.isEmpty()) {
				cur = q.poll();
				map[cur] = ind++;
				for (int i : adj[cur])
					q.add(i);
			}
			// ORIGINAL IDs -> NEW IDS
			for (int i = 0; i < N; i++)
				if (par[i] != -1)
					par[i] = map[par[i]];
			l = new int[N];
			r = new int[N];
			for (int i = 0; i < N; i++) {
				// use mapped IDs for left/right children
				if (adj[i].size() == 0)
					l[i] = r[i] = -1;
				else {
					l[i] = r[i] = map[adj[i].get(0)];
					for (int k : adj[i])
						r[i] = map[k];
				}
			}

			// initialize segtree - probability a node lives
			st = new Node(0, N - 1);
			for (int i = 0; i < N; i++)
				st.set(map[i], 1 - iprob[i]);

			Q = s.nextInt();
			for (int qu = 1; qu <= Q; qu++) {
				int x = s.nextInt(), mx = map[x];
				double newProb = 1 - s.nextDouble();
				double changeInProb = newProb - st.get(mx);
				double adj = (l[x] == -1 ? 0 : st.sum(l[x], r[x])) + (par[x] == -1 ? 0 : st.get(par[x]));
				st.set(mx, newProb);
				EXP_NODES = st.sum(0, N - 1);
				EXP_EDGES += changeInProb * adj;
				out.printf("%.12f%n", EXP_NODES - EXP_EDGES);
			}
		}

		class Node {

			int l, m, r;
			double sum;
			Node L, R;

			Node(int ll, int rr) {
				l = ll;
				r = rr;
				m = l + (r - l) / 2;
				if (ll == rr)
					return;
				sum = 0;
				L = new Node(l, m);
				R = new Node(m + 1, r);
			}

			void set(int i, double x) {
				if (l == i && r == i) {
					sum = x;
					return;
				}
				if (i <= m)
					L.set(i, x);
				else
					R.set(i, x);
				sum = L.sum + R.sum;
			}

			double get(int i) {
				return sum(i, i);
			}

			double sum(int s, int e) {
				if (s <= l && r <= e)
					return sum;
				double res = 0;
				if (s <= m)
					res += L.sum(s, e);
				if (m < e)
					res += R.sum(s, e);
				return res;
			}

		}

	}

	static class BruteSolver {

		int N, Q, edges[][];
		double plive[], pfall[], EXP_NODES, EXP_EDGES;

		void solve(FastScanner s, PrintWriter out) {
			EXP_NODES = N = s.nextInt();
			pfall = s.nextDoubleArray(N);
			plive = new double[N];
			for (int i = 0; i < N; i++) {
				plive[i] = 1 - pfall[i];
				EXP_NODES -= pfall[i];
			}
			edges = s.next2DIntArray(N - 1, 2);
			Q = s.nextInt();
			for (int q = 1; q <= Q; q++) {
				int x = s.nextInt();
				double np = s.nextDouble();
				EXP_NODES -= np - pfall[x];
				plive[x] = 1 - (pfall[x] = np);
				EXP_EDGES = 0;
				for (int[] e : edges)
					EXP_EDGES += plive[e[0]] * plive[e[1]];
				out.printf("%.12f%n", EXP_NODES - EXP_EDGES);
			}
		}

	}

	public static void main(String[] args) {

		FastScanner s = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Solver solver = new Solver();
		solver.solve(s, out);

		out.close();
		s.close();

	}

	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
		}

		public FastScanner(File f) throws FileNotFoundException {
			this(new FileInputStream(f));
		}

		public FastScanner(String s) {
			this.stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
		}

		void close() {
			try {
				stream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}

		// Jacob Garbage

		public int[] nextIntArray(int N) {
			int[] ret = new int[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextInt();
			return ret;
		}

		public int[][] next2DIntArray(int N, int M) {
			int[][] ret = new int[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextIntArray(M);
			return ret;
		}

		public long[] nextLongArray(int N) {
			long[] ret = new long[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextLong();
			return ret;
		}

		public long[][] next2DLongArray(int N, int M) {
			long[][] ret = new long[N][];
			for (int i = 0; i < N; i++)
				ret[i] = nextLongArray(M);
			return ret;
		}

		public double[] nextDoubleArray(int N) {
			double[] ret = new double[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDouble();
			return ret;
		}

		public double[][] next2DDoubleArray(int N, int M) {
			double[][] ret = new double[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDoubleArray(M);
			return ret;
		}

	}

}
