Wookje Is a Devoted Son!!
Time limit2sMemory limit512 MB
Given edge costs of a cycle of n villages, find the minimum total cost for three travelers starting at one village to collectively visit every village.
- Level
Medium4 of 10
- Topics
- Greedy, Implementation, Array, Brute force
- Solved
- No attempts yet
Problem
To mark the occasion of bombing the KOI, Wookje went on a trip to Codegate Island with his parents. Codegate Island has many tourist spots, such as Junoh Village, famous for its squid (not Junoh Lim the grumpy hacker), Jaehoon Village, famous for its rice, and Youngjoong Village. Wookje wants to take his parents around Codegate Island.
The villages of Codegate Island lie in a circle along the coast. To go from any village A to any village B, you travel around the island along the coast, taking either the road to the left or the road to the right. There is no road other than this circular one around the island.

You are given the travel cost between each pair of neighboring villages. Tell Wookje the minimum travel cost he needs to prepare so that he and his parents can visit every village on the island.
Input
The first line contains the number of villages . ()
The second line contains travel costs . is the travel cost between village and village , and the -th value is the travel cost between village and village . ()
Output
Print the minimum travel cost needed to visit every village.