#P3918. [国家集训队] 特技飞行

[国家集训队] 特技飞行

Description

Shenben Airlines (pinyin) has launched a passenger-carrying stunt flying service. Each flight lasts nn time units. In each time unit, you can perform one stunt. There are kk types of stunts, and each type has an excitement level cic_i. If the same stunt is performed repeatedly, passengers get bored, so we define the value of performing a stunt as (time since the last time this same stunt was performed) ×ci \times c_i. If it is the first time performing that stunt, the value is 00. Plan a schedule to maximize the total value.

Input Format

The first line contains two integers, nn and kk, as described above. The second line contains kk integers, the cic_i values for the kk stunt types.

Output Format

Output a single line with one integer, the maximum total value.

5 2
2 2
12


Hint

Constraints

  • For 10% of the testdata, n20n \le 20, k3k \le 3.
  • For 100% of the testdata, 1n1031 \le n \le 10^3, 1k3001 \le k \le 300, 0ci1030 \le c_i \le 10^3.

Translated by ChatGPT 5