import java.io.*; import java.util.*; class Main { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); String s[]=bu.readLine().split(" "); int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]); int i,b[]=new int[n]; long dp[][]=new long[n][2],ans=0; for(i=0;i0) { dp[i][0]=dp[i-1][0]; //0 means no coin bought to store dp[i][1]=dp[i-1][0]-c; //1 means coin bought to store } else dp[i][1]=-c; int j,x; s=bu.readLine().split(" "); for(j=0;j