#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[1000005], ans = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    ans += abs(a[i - 1] - a[i]);
  }
  cout << ans;
}
