Codeforces Problem 455A - Boredom


Submit solution

Points: 300
Time limit: 1.0s
Memory limit: 8M

Author:
Problem type
Allowed languages
C, C++

Codeforces Problem 455A - Boredom

给定一个整数序列 \(a_1,a_2...a_n\),你可以进行若干次操作。每次操作中,你可以选择一个数 \(a_i\) 并获得的点数。

之后,必须从序列中删除所有等于\(a_{i-1}\)和\(a_{i+1}\)的元素。 你的目标是通过这些操作获得尽可能多的点数。

输入格式

输入

第一行输入整数n

第二行输入n个整数

输出

输出尽可能多的点数

示例1

输入

2
1 2

输出

2

示例2

输入

3
1 2 3

输出

4

示例2

输入

9
1 2 1 3 2 2 2 2 3

输出

10

数据制约

\(1 \le n \le 10^5\)
\(1 \le a_i \le 10^5\)


Comments

There are no comments at the moment.