#include #include #include #include #include #include #include using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); }; } fio; signed main(){ cout< Y; vector> dp; cin>>N; Y.resize(N); dp.resize(2, vector(MAX, INF)); for(int i = 0; i < N; i++){ cin>>Y[i]; Y[i] += offset; } for(int i = 0; i < MAX; i++){ dp[0][i] = 0; } for(int i = 0; i < N; i++){ for(int j = 0; j < MAX; j++){ dp[(i+1)%2][j] = min(dp[(i+1)%2][j], dp[(i)%2][j] + abs(Y[i] - j)); } for(int j = 0; j < MAX; j++){ if(j) dp[(i+1)%2][j] = min(dp[(i+1)%2][j-1], dp[(i+1)%2][j]); dp[i%2][j] = INF; } } cout<