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