Intervals on Tree#10667

Intervals on Tree

1 second
128 megabytes
Very easy

We have a tree with vertices and n - 1 edges, respectively numbered , , ..., and , , ..., n - 1. Edge connects vertices u_i and v_i.

For integers , (1 \le L \le R \le n), let us define a function f(L, R) as follows:

prb10667.gif

Compute

Input

The first line contains number (1 \le n \le 2 \cdot 10^5). Each of the next n - 1 lines contains two vertices (u_i, v_i) (1 \le u_i, v_i \le n) - an edge in the graph.

Output

Print the value of the sum.

Examples

Example 1

Loading
Loading

Note

We have six possible pairs (, ) as follows:

For L = 1, R = 1, S = \{1\} and we have connected component.

For L = 1, R = 2, S = \{1, 2\} and we have connected components.

For L = 1, R = 3, S = \{1, 2, 3\} and we have connected component, since contains both endpoints of each of the edges , .

For L = 2, R = 2, S = \{2\} and we have connected component.

For L = 2, R = 3, S = \{2, 3\} and we have connected component, since contains both endpoints of Edge .

For L = 3, R = 3, S = \{3\} and we have connected component.

The sum of these is .