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

public class InterstellarBattle {
    static ArrayList<Integer>[] graph;
    static double[] vals;
    static int[] par;
    static double[] tots;
    static double sumEdges = 0;
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        vals = new double[N+1];
        graph = new ArrayList[N];
        for(int i = 0; i < N; i++) graph[i] = new ArrayList<>();
        double sum = 0;
        for(int i = 0; i < N; i++) {
            vals[i] = 1.0-scanner.nextDouble();
            sum += vals[i];
        }
        int[][] edges = new int[N][2];
        for(int i = 1; i < N; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            graph[a].add(b);
            graph[b].add(a);
            edges[i-1][0] = a;
            edges[i-1][1] = b;
        }
        //edges only computed in the parent, sum kept seperately.
        tots = new double[N +1];
        par = new int[N];
        dfs(0, N);
        int Q = scanner.nextInt();
        while(Q-->0) {
            int ind = scanner.nextInt();
            double nval = 1.0-scanner.nextDouble();
            sumEdges -= vals[ind] * tots[ind];
            sum -= vals[ind];
            sumEdges -= tots[par[ind]] * vals[par[ind]];
            tots[par[ind]] -= vals[ind];
            vals[ind] = nval;
            sumEdges += vals[ind] * tots[ind];
            tots[par[ind]] += vals[ind];
            sumEdges += tots[par[ind]] * vals[par[ind]];
            sum += vals[ind];
            out.println(sum - sumEdges);
//            double nsum = 0;
//            for(int i = 0; i < N; i++) {
//                nsum += vals[i];
//            }
//            double lnsum = 0;
//            for(int i = 0; i < N-1; i++) {
//                lnsum += vals[edges[i][0]] * vals[edges[i][1]];
//            }
//            out.println(nsum - lnsum);
        }
        out.flush();
    }
    
    static void dfs(int v, int p) {
        par[v] = p;
        for(int edge: graph[v]) {
            if (edge == p) continue;
            tots[v] += vals[edge];
            dfs(edge, v);
        }
        sumEdges += vals[v] * tots[v];
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}
