시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 93 64 48 68.571%

문제

JOI 군과 IOI 양은 쌍둥이 남매이다. JOI 군은 최근 과자 만들기에 푹 빠졌기 때문에, JOI 군은 오늘도 케이크를 만들어서 먹으려고 했지만, 막 구워진 참에 냄새를 맡고 온 IOI 양이 왔기 때문에 두 명이 케이크를 나누어 먹기로 했다.

케이크는 둥그런 모양을 하고 있다. 어느 점에서부터 직선으로 칼집을 넣어 케이크를 N 개의 조각으로 나눈 뒤, 각 조각마다 1부터 N 까지 반시계방향으로 번호를 매긴다. 즉, 1 ≦ i ≦ N에 대해, i 번째 조각은 i - 1 번째와 i + 1 번째 조각과 인접해있다. (단, 0번째는 N 번째, N + 1 번째는 1번째로 간주한다). i 번째 조각의 크기는 Ai 이지만, 칼질이 서툴러 Ai가 모두 다른 값을 가지게 되었다.

그림 1 : 케이크의 예 (N = 5, A1 = 2, A2 = 8, A3 = 1, A4 = 10, A5 = 9)

이 N개를 JOI 군과 IOI 양이 나누기로 하였다. 나누는 방법은 다음과 같다.

  1. 먼저, JOI 군이 N 개의 조각 중 원하는 것 하나를 가져간다.
  2. 그 뒤, IOI 양으로부터 시작해 IOI 양과 JOI 군은 번갈아가며 남은 조각을 하나씩 가져간다. 단, 인접한 조각 중 하나 이상의 조각이 이미 선택된 경우에만 가져갈 수 있다. 가져갈 수 있는 조각이 여러 개 있을 때엔, IOI 양은 그 중 가장 큰 조각을 가져가고, JOI 군은 원하는 조각을 가져갈 수 있다.

JOI 군은 자신이 가져온 조각들 크기의 합을 최대화하고 싶다.

케이크의 조각 수 N 과, N 개의 조각의 크기에 대한 정보가 주어질 때, JOI 군이 가져올 수 있는 조각들의 합계의 최대치를 구하는 프로그램을 작성하시오.

입력

표준입력으로부터 이하의 입력이 주어진다.

  • 첫 번째 줄에는 케이크가 N 개의 조각으로 나뉘어 있음을 나타내는 정수 N이 주어진다.
  • 이어지는 N 열 중 i 열 (1 ≦ i ≦ N) 에는 i 번째 조각의 크기를 나타내는 정수 Ai가 적혀있다.

모든 입력 데이터는 아래의 조건을 만족한다.

  • 1 ≦ N ≦ 2 000.
  • 1 ≦ Ai ≦ 1 000 000 000.
  • Ai 모두 다른 값을 갖는다.

출력

JOI 군이 가져올 수 있는 조각들의 합계의 최대치를 한 줄로 출력하시오.

예제 입력 1

5
2
8
1
10
9

예제 출력 1

18

예제 입력 2

8
1
10
4
5
6
2
9
3

예제 출력 2

26

예제 입력 3

15
182243672
10074562
977552215
122668426
685444213
3784162
463324752
560071245
134465220
21447865
654556327
183481051
20041805
405079805
564327789

예제 출력 3

3600242976

힌트

JOI 군이 다음과 같은 순서로 케이크를 가져오는 것이 최적해이다.

  1. JOI 군이 2번째 조각을 가져온다. 이 조각의 크기는 8이다.
  2. IOI 양은 1번째 조각을 가져온다. 이 조각의 크기는 2이다.
  3. JOI 군이 5번째 조각을 가져온다. 이 조각의 크기는 9이다.
  4. IOI 양은 4번째 조각을 가져온다. 이 조각의 크기는 10이다.
  5. JOI 군이 3번째 조각을 가져온다. 이 조각의 크기는 1이다.

최종적으로, JOI 군이 가져온 조각들 크기의 합계는 8+9+1 = 18이 된다.

W3sicHJvYmxlbV9pZCI6IjEwNzE0IiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHVjZjAwXHVjNzc0XHVkMDZjIFx1Yzc5MFx1Yjk3NFx1YWUzMCAyIiwiZGVzY3JpcHRpb24iOiI8cD5KT0kgXHVhZDcwXHVhY2ZjIElPSSBcdWM1OTFcdWM3NDAgXHVjMzBkXHViNDY1XHVjNzc0IFx1YjBhOFx1YjllNFx1Yzc3NFx1YjJlNC4gSk9JIFx1YWQ3MFx1Yzc0MCBcdWNkNWNcdWFkZmMgXHVhY2ZjXHVjNzkwIFx1YjljY1x1YjRlNFx1YWUzMFx1YzVkMCBcdWQ0NzkgXHViZTYwXHVjODRjXHVhZTMwIFx1YjU0Y1x1YmIzOFx1YzVkMCwgSk9JIFx1YWQ3MFx1Yzc0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