Do you know that every country has its own symbolic tree? In Greece, it is the olive tree, in Japan — the sakura, in Canada — the maple, in Australia — the golden wattle (mimosa), in Nordlandia and Finland — the birch.
The tree that holds a special place in Azerbaijani folklore and has become a symbol of Azerbaijan is the Chinar (Plane tree).
Since ancient times, the Chinar has been surrounded by respect. Even the Romans knew and used its healing properties: decoctions of its fruits stopped bleeding, treated burns and frostbite, and infusions from its bark were used for snake bites. Nowadays, the bark of young trunks is even used in cancer treatment, while decoctions and ointments made from the fruits help with various ailments.
Imagine a huge Chinar tree grown in one of the parks of Baku. It has branches, and each branch is colored either white or black. But such a multicolored appearance disrupts its majestic harmony. Therefore, it was decided to repaint the tree so that it becomes completely one color — either white or black.
Only one operation is available for this: , where is a chosen vertex of the tree. This operation flips the color of all vertices such that on the shortest path from to , all vertices have the same color (including the vertices and themselves).
For example, the tree on the left, after applying the operation , will change its coloring as shown on the right.
Your task is to determine the minimum number of operations required to repaint the Chinar so that it becomes entirely one color.
The first line contains a single integer (1 \le n \le 200\,000) — the number of vertices of the tree.
The second line contains integers color_i (0 \le color_i \le 1) — the colors of the vertices. If color_i = 0, the -th vertex is white; if color_i = 1, it is black.
Each of the following n - 1 lines contains two integers u_i and v_i (1 \le u_i, v_i \le n, u_i \ne v_i) — the edges of the tree. It is guaranteed that all edges are distinct, so the graph contains no multiple edges.
Print a single integer — the minimum number of repaint operations required to make the Chinar completely white or completely black.
Example 1
Example 2