import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;

@SuppressWarnings("unchecked")
public class D1045 {
	
	int n;
	ArrayList<Integer>[] vs;
	double[] p;
	int[] par;
	double[] childSum;
	
	void dfs(int node, int pa) {
		par[node] = pa;
		double sum = 0;
		for(int v : vs[node]) if(v != pa) {
			dfs(v, node);
			sum += 1 - p[v];
		}
		childSum[node] = sum;
	}
	
	public void solve(JoltyScanner in, PrintWriter out) {
		n = in.nextInt();
		vs = new ArrayList[n];
		p = new double[n];
		par = new int[n];
		childSum = new double[n];
		for(int i = 0; i < n; ++i) {
			vs[i] = new ArrayList<>();
			p[i] = in.nextDouble();
		}
		for(int i = 0; i < n - 1; ++i) {
			int u = in.nextInt(), v = in.nextInt();
			vs[u].add(v); vs[v].add(u);
		}
		dfs(0, -1);
		double ans = 0;
		for(int u = 0; u < n; ++u) ans += p[u] * childSum[u];
		ans += 1 - p[0];
		int q = in.nextInt();
		while(q-->0) {
			int node = in.nextInt();
			double np = in.nextDouble();
			double children = childSum[node];
			
			//take out all things with previous probability
			{
				double contrib = 1 - p[node];
				if(par[node] != -1) {
					contrib *= p[par[node]];
					childSum[par[node]] -= 1 - p[node];
				}
				ans -= contrib;
				ans -= children * p[node];
			}
			
			//add in stuff with new probability
			p[node] = np;
			{
				double contrib = 1 - p[node];
				if(par[node] != -1) {
					contrib *= p[par[node]];
					childSum[par[node]] += 1 - p[node];
				}
				ans += contrib;
				ans += children * p[node];
			}
			
			out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		JoltyScanner in = new JoltyScanner();
		PrintWriter out = new PrintWriter(System.out);
		new D1045().solve(in, out);
		out.close();
	}
	
	static class JoltyScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JoltyScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JoltyScanner(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
	        while(c!='.'&&c!='-'&&(c <'0' || c>'9')) c = nextChar();
	        boolean neg = c=='-';
	        if(neg)c=nextChar();
	        boolean fl = c=='.';
	        double cur = nextLong();
	        if(fl) return neg ? -cur/num : cur/num;
	        if(c == '.') {
	            double next = nextLong();
	            return neg ? -cur-next/num : cur+next/num;
	        }
	        else return neg ? -cur : cur;
	    }

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}

}
