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