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