Gift
InterviewTime limit1sMemory limit1024 MB
Given the daily sock prices, find the minimum cost to buy X socks on each of two consecutive days, 2X socks in total.
- Level
Easy2 of 10
- Topics
- Array, Implementation
- Solved
- No attempts yet
Problem
Dongwon's birthday is days from now. Let's congratulate him!
Junwon plans to give Dongwon socks as a birthday present. He will buy the socks at a market. Over two consecutive days, Junwon buys socks each day and loads them into a truck.
Sock prices at the market can differ from day to day. On the -th day counting from today, one sock costs won.
There are days left until Dongwon's birthday. Among those days, what is the minimum cost to buy socks over two consecutive days?
Input
The first line contains and , separated by a space.
The second line contains the sock prices for the days, separated by spaces.
Output
Print the minimum cost to buy socks by buying socks per day over two consecutive days.
Constraints
- ()