#include <bits/stdc++.h>
using namespace std;
long long b[200005] = {0};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long i = 0, n, curr = 0, steps = 0;
  cin >> n;
  for (i = 0; i < n; i++) cin >> b[i];
  steps = abs(b[0]);
  for (i = 1; i < n; i++) {
    long long diff = abs(b[i] - b[i - 1]);
    steps += diff;
  }
  cout << steps;
  return 0;
}
