#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    long n;
    std::vector<int> dp(100010);
    std::cin >> n; 
    std::vector<int> h_vec;
    int h;
    while (std::cin >> h) {
        h_vec.push_back(h);
    }
    for (int i = 1; i < n; i++) {
        if (i == 1) {
            dp[i] = std::abs(h_vec[i] - h_vec[i - 1]);
        } else {
            dp[i] = std::min(dp[i - 2] + std::abs(h_vec[i - 2] - h_vec[i]), dp[i - 1] + std::abs(h_vec[i - 1] - h_vec[i]));
        }
    }
    std::cout << dp[n - 1] << std::endl;
}
