CF884C Bertown Subway
Description
The construction of subway in Bertown is almost finished! The President of Berland will visit this city soon to look at the new subway himself.
There are $ n $ stations in the subway. It was built according to the Bertown Transport Law:
1. For each station $ i $ there exists exactly one train that goes from this station. Its destination station is $ p_{i} $ , possibly $ p_{i}=i $ ;
2. For each station $ i $ there exists exactly one station $ j $ such that $ p_{j}=i $ .
The President will consider the convenience of subway after visiting it. The convenience is the number of ordered pairs $ (x,y) $ such that person can start at station $ x $ and, after taking some subway trains (possibly zero), arrive at station $ y $ ( $ 1
Input Format
The first line contains one integer number $ n $ ( $ 1
Output Format
Print one number — the maximum possible value of convenience.
Explanation/Hint
In the first example the mayor can change $ p_{2} $ to $ 3 $ and $ p_{3} $ to $ 1 $ , so there will be $ 9 $ pairs: $ (1,1) $ , $ (1,2) $ , $ (1,3) $ , $ (2,1) $ , $ (2,2) $ , $ (2,3) $ , $ (3,1) $ , $ (3,2) $ , $ (3,3) $ .
In the second example the mayor can change $ p_{2} $ to $ 4 $ and $ p_{3} $ to $ 5 $ .