Frog
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
The frog has a very busy weekend, it needs to jump over all \(n\) stones arranged in a row.
Initially, the frog is on the first stone and it wants to visit every other stone exactly once. To jump from stone \(x\) to stone \(y\), the frog spends \((|x-y|-3)^2\) energy. That is, if the distance between the stones is 3, no energy is required for such a jump.
Help the frog and find the minimum amount of energy it needs to spend to visit each stone exactly once.
Input
The first line gives a single integer \(n\) — the number of stones.
Output
Output a single number — the minimum amount of energy the frog needs to spend to visit each stone exactly once.
Constraints
\(2 \le n \le 10^5\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 4 | 5 |
| Input (stdin) | Output (stdout) |
|---|---|
| 7 | 2 |
| Input (stdin) | Output (stdout) |
|---|---|
| 10 | 3 |
Notes
In the first example, the optimal path of the frog is \(1 \to 4 \to 2 \to 3\). For this path, the frog spends 5 energy:
Jump from stone 1 to stone 4 — 0 energy;
Jump from stone 4 to stone 2 — 1 energy;
Jump from stone 2 to stone 3 — 4 energy.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|