Given a tree with n nodes numbered from 1 to n. Each node i has an associated value V_i.

If the simple path from u_1 to u_m consists of m nodes namely u_1 → u_2 → u_3 → ... u_{m-1} → u_{m}, then its alternating function A(u_{1},u_{m}) is defined as A(u_{1},u_{m}) = ∑_{i=1}^{m} (-1)^{i+1} ⋅ V_{u_{i}}. A path can also have 0 edges, i.e. u_{1}=u_{m}.

Compute the sum of alternating functions of all unique simple paths. Note that the paths are directed: two paths are considered different if the starting vertices differ or the ending vertices differ. The answer may be large so compute it modulo 10^{9}+7. 

Input

The first line contains an integer n (2 ≤ n ≤ 2⋅10^{5} ) — the number of vertices in the tree.

The second line contains n space-separated integers V_1, V_2, …, V_n (-10^9≤ V_i ≤ 10^9) — values of the nodes.

The next n-1 lines each contain two space-separated integers u and v (1≤ u, v≤ n, u ≠ v) denoting an edge between vertices u and v. It is guaranteed that the given graph is a tree.

Output

Print the total sum of alternating functions of all unique simple paths modulo 10^{9}+7. 

Examples

Input

4
-4 1 5 -2
1 2
1 3
1 4


Output

40


Input

8
-2 6 -4 -4 -9 -3 -7 23
8 2
2 3
1 4
6 5
7 6
4 7
5 8


Output

4

Note

Consider the first example.

A simple path from node 1 to node 2: 1 → 2 has alternating function equal to A(1,2) = 1 ⋅ (-4)+(-1) ⋅ 1 = -5.

A simple path from node 1 to node 3: 1 → 3 has alternating function equal to A(1,3) = 1 ⋅ (-4)+(-1) ⋅ 5 = -9.

A simple path from node 2 to node 4: 2 → 1 → 4 has alternating function A(2,4) = 1 ⋅ (1)+(-1) ⋅ (-4)+1 ⋅ (-2) = 3.

A simple path from node 1 to node 1 has a single node 1, so A(1,1) = 1 ⋅ (-4) = -4.

Similarly, A(2, 1) = 5, A(3, 1) = 9, A(4, 2) = 3, A(1, 4) = -2, A(4, 1) = 2, A(2, 2) = 1, A(3, 3) = 5, A(4, 4) = -2, A(3, 4) = 7, A(4, 3) = 7, A(2, 3) = 10, A(3, 2) = 10. So the answer is (-5) + (-9) + 3 + (-4) + 5 + 9 + 3 + (-2) + 2 + 1 + 5 + (-2) + 7 + 7 + 10 + 10 = 40.

Similarly A(1,4)=-2, A(2,2)=1, A(2,1)=5, A(2,3)=10, A(3,3)=5, A(3,1)=9, A(3,2)=10, A(3,4)=7, A(4,4)=-2, A(4,1)=2, A(4,2)=3 , A(4,3)=7 which sums upto 40. 
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.InputMismatchException;

public class Main {
  private static final int MOD = 1000000007;
  
	public static void main(String[] args) {
		FasterScanner sc = new FasterScanner();

    int N = sc.nextInt();
    
    Node[] nodes = new Node[N + 1];
    for (int i = 1; i <= N; ++i) {
      long V = sc.nextLong();
      
      nodes[i] = new Node(V);
    }
    
    for (int i = 1; i < N; ++i) {
      int U = sc.nextInt();
      int V = sc.nextInt();
      
      nodes[U].next.add(nodes[V]);
      nodes[V].next.add(nodes[U]);
    }
    
    rootify(nodes[1], null);
    oeb(nodes[1]);
    oea(nodes[1], 0, 0);
    
    long total = 0;
    for (int i = 1; i <= N; ++i) {
      Node u = nodes[i];
      long posCnt = 0;
      long negCnt = 0;
      for (Node v : u.next) {
        posCnt += v.evenBelow * (u.total() - v.below());
        negCnt += v.oddBelow * (u.total() - v.below());
        posCnt %= MOD;
        negCnt %= MOD;
      }
      posCnt += u.total();
      posCnt += u.oddAbove * u.below();
      negCnt += u.evenAbove * u.below();
      posCnt %= MOD;
      negCnt %= MOD;
      long delta = u.val * (posCnt - negCnt);
      total = (((total + delta) % MOD) + MOD) % MOD;
    }
    System.out.println(total);
	}
	
	public static class Node {
	  public HashSet<Node> next = new HashSet<>();
	  public long val;
	  public long oddBelow;
	  public long evenBelow;
	  public long oddAbove;
	  public long evenAbove;
	  
	  public Node(long v) {
	    this.val = v;
	  }
	  
	  public long odd() {
	    return this.oddBelow + this.oddAbove;
	  }
	  
	  public long even() {
	    return this.evenBelow + this.evenAbove;
	  }
	  
	  public long below() {
	    return this.oddBelow + this.evenBelow;
	  }
	  
	  public long above() {
	    return this.oddAbove + this.evenAbove;
	  }
	  
	  public long total() {
	    return this.odd() + this.even();
	  }
	}
	
	public static void rootify(Node u, Node p) {
	  u.next.remove(p);
	  for (Node v : u.next) {
	    rootify(v, u);
	  }
	}
	
	public static void oeb(Node u) {
	  for (Node v : u.next) {
	    oeb(v);
	    u.oddBelow += v.evenBelow;
	    u.evenBelow += v.oddBelow;
	    u.oddBelow %= MOD;
	    u.evenBelow %= MOD;
	  }
	  ++u.oddBelow;
    u.oddBelow %= MOD;
	}
	
	public static void oea(Node u, long odd, long even) {
	  u.oddAbove += even;
	  u.evenAbove += odd;
	  long oddCnt = even + 1;
	  long evenCnt = odd;
	  for (Node v : u.next) {
	    oddCnt += v.evenBelow;
	    evenCnt += v.oddBelow;
	    oddCnt %= MOD;
	    evenCnt %= MOD;
	  }
	  for (Node v : u.next) {
	    oea(v, oddCnt - v.evenBelow, evenCnt - v.oddBelow);
	  }
	}

	public static class FasterScanner {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

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

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

		public String nextString() {
			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 long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			return nextIntArray(n, 0);
		}

		public int[] nextIntArray(int n, int off) {
			int[] arr = new int[n + off];
			for (int i = 0; i < n; i++) {
				arr[i + off] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			return nextLongArray(n, 0);
		}

		public long[] nextLongArray(int n, int off) {
			long[] arr = new long[n + off];
			for (int i = 0; i < n; i++) {
				arr[i + off] = nextLong();
			}
			return arr;
		}

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

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