시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB66632725454.274%

문제

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가 적혀있다.

출력

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

제한

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

서브태스크

번호 배점 제한
1 15

N ≦ 20

2 45

N ≦ 300

3 40

추가적인 제약 조건이 없다.

예제 입력 1

5
2
8
1
10
9

예제 출력 1

18

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이 된다.

예제 입력 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
W3sicHJvYmxlbV9pZCI6IjEwNzE0IiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHVjZjAwXHVjNzc0XHVkMDZjIFx1Yzc5MFx1Yjk3NFx1YWUzMCAyIiwiZGVzY3JpcHRpb24iOiI8cD5KT0kgXHVhZDcwXHVhY2ZjIElPSSBcdWM1OTFcdWM3NDAgXHVjMzBkXHViNDY1XHVjNzc0IFx1YjBhOFx1YjllNFx1Yzc3NFx1YjJlNC4gSk9JIFx1YWQ3MFx1Yzc0MCBcdWNkNWNcdWFkZmMgXHVhY2ZjXHVjNzkwIFx1YjljY1x1YjRlNFx1YWUzMFx1YzVkMCBcdWQ0NzkgXHViZTYwXHVjODRjXHVhZTMwIFx1YjU0Y1x1YmIzOFx1YzVk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