QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#12571. Wizard Examination

统计

Apprentice magical girl Chiaro is taking a wizardry exam. The great wizard Shiro has placed $n$ magic orbs with no magic power in front of her. Chiaro needs to perform several spells to make these magic orbs reach specified magic power levels.

Specifically, initially, the magic power of all these orbs is 0. Chiaro needs to perform several spells so that the $i$-th magic orb eventually has a magic power of $a_i$. However, as an apprentice, Chiaro has limited knowledge of magic. She only knows two types of spells, and each spell consumes a certain amount of stamina:

  • Increase the magic power of any single magic orb by 1, which consumes $x$ stamina.
  • Choose any interval $[l, r]$ and double the magic power of all magic orbs from the $l$-th to the $r$-th (a total of $r - l + 1$ orbs), which consumes $y$ stamina.

Clearly, Chiaro can always complete this test using only the two spells mentioned above. However, this wizardry exam has just begun, and there are many more difficult tasks ahead. Therefore, Chiaro wants to complete this test using the minimum amount of stamina. Please help her calculate the minimum stamina required to complete this test.

Input

The first line contains three non-negative integers $n, x, y$ ($1 \le n \le 3 \times 10^5, 0 \le x, y \le 10^7$).

The next line contains $n$ non-negative integers representing the sequence $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 10^9$).

Output

A single integer representing the minimum stamina consumed.

Examples

Input 1

6 1 1
1 1 4 5 1 4

Output 1

9

Input 2

5 2 5
10 7 9 0 3

Output 2

32

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.