Problem Statement
Given an integer array a[1..N] and a penalty value P , select a subsequence of elements to maximize total sum . Every gap in the chosen indices — two consecutive picks at positions i and j where j > i + 1 — costs exactly P . Find the maximum achievable score . Input Format The first line contains a integer, n , denoting the size of the array. The second line contains a integer, P , denoting the penalty per gap in chosen indices. Each line i of the n subsequent lines (where 0 ≤ i < n ) contains a integer, a[i] .