#include #include #include using namespace std; const long long INF = 1000000000000000; int main(){ int N; cin >> N; vector Y(N); for (int i = 0; i < N; i++){ cin >> Y[i]; } vector dp(N + 1, INF); dp[0] = 0; for (int i = 0; i < N; i++){ if (i + 2 <= N){ dp[i + 2] = min(dp[i + 2], dp[i] + Y[i + 1] - Y[i]); } if (i + 3 <= N){ dp[i + 3] = min(dp[i + 3], dp[i] + Y[i + 2] - Y[i]); } } cout << dp[N] << endl; }