#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef pair P; int main() { int n; ll p; cin>>n>>p; ll s1[200001], s2[200001]; s1[0]=0, s2[0]=0; ll h[200001]; ll dp[200001], mn1[200001], mn2[200001]; for(int i=0; i>h[i]; if(i>0){ s1[i]=s1[i-1]+max(h[i]-h[i-1], 0ll); s2[i]=s2[i-1]+max(h[i-1]-h[i], 0ll); } } dp[0]=0, mn1[0]=-s1[1], mn2[0]=-s2[1]; for(int i=1; i