Under construction

Still being built. Things may change

Network Investment

Interview

Time limit1sMemory limit128 MB

Summary
Find the tree edge whose removal maximizes the product of the two component sizes.
Level

Easy3 of 10

Topics
DFS, Tree
Solved
No attempts yet

Problem

The computer network of Byteland consists of nn nodes connected by fiber-optic links. The fiber network is not dense: between any two nodes there is exactly one path (possibly passing through intermediate nodes), so the network forms a single tree. Because of this, some links carry heavy traffic and cause large delays in transmitting information.

The traffic in the network is quite heavy and evenly spread. That is, in every unit of time every pair of nodes exchanges exactly one packet of information with each other. The load of a link is the number of packets that pass through that link in one unit of time. (If a link is removed the network splits into two parts, and the load of that link equals the number of nodes on one side multiplied by the number of nodes on the other side.)

The company managing the network wants to know whether the load is large enough that the network needs to be upgraded or expanded. To decide this, it needs to know the load of the most heavily loaded link.

Write a program that computes the load of the most heavily loaded link in the network.

Input

The first line contains the number of nodes nn (1≤n≤10001 \le n \le 1000). The nodes are numbered from 11 to nn. Each of the next n−1n - 1 lines describes one link, one per line. Each line contains two integers separated by a space, giving the numbers of the two nodes connected by that link.

Output

Output a single integer: the load of the most heavily loaded link in the network.

Examples1

  1. Example 1

    Input
    5
    1 2
    2 3
    3 4
    3 5
    
    Expected output
    6