(n, c) = map(int, input().split(' '))
prices = list(map(int, input().split(' ')))
comparison = []
for i in range(n - 1):
if prices[i] > prices[i + 1]:
comparison.append(prices[i] - prices[i + 1])
if len(comparison) == 0:
print(0)
else:
if c > max(comparison):
print(0)
else:
print(max(comparison) - c)
//
// main.cpp
// A. Bear and Raspberry
//
// Created by Farrah Tharwat on 28/02/2023.
//
#include <iostream>
#include <map>
#include <vector>
//#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main() {
int n,r;
cin>>n>>r;
int a[n];
//vector<int> v;
int maxx=0;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n-1;i++){
//v.push_back(a[i]-a[i+1]);
maxx = max((a[i]-a[i+1]),maxx);
}
if((maxx-r)>=0)
cout<<maxx-r<<endl;
else
cout<<0<<endl;
//laptops
// int n,a,b;
// cin>>n;
// vector<pair<int , int>> v;
// while(n--){
// cin>>a>>b;
// v.push_back(make_pair(a, b));
// }
// sort(v.begin(), v.end());
// int x = v.begin()->second;
// vector<pair<int , int>>::iterator it;
// bool flag=0;
// for(it=v.begin();it!=v.end();++it){
// if(it->second < x)flag=1;
// x=it->second;
// }
// if(flag)
// cout<<"Happy Alex"<<endl;
// else
// cout<<"Poor Alex"<<endl;
}
1400C - Binary String Reconstruction | 1734D - Slime Escape |
1499A - Domino on Windowsill | 991A - If at first you don't succeed |
1196C - Robot Breakout | 373A - Collecting Beats is Fun |
965A - Paper Airplanes | 863E - Turn Off The TV |
630E - A rectangle | 1104A - Splitting into digits |
19C - Deletion of Repeats | 1550B - Maximum Cost Deletion |
1693A - Directional Increase | 735D - Taxes |
989A - A Blend of Springtime | 339C - Xenia and Weights |
608A - Saitama Destroys Hotel | 1342C - Yet Another Counting Problem |
548A - Mike and Fax | 109A - Lucky Sum of Digits |
864C - Bus | 626B - Cards |
1221A - 2048 Game | 1374D - Zero Remainder Array |
1567C - Carrying Conundrum | 1029C - Maximal Intersection |
922C - Cave Painting | 811C - Vladik and Memorable Trip |
1589C - Two Arrays | 1510K - King's Task |