#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  scanf("%d", &n);
  vector<int> arr;
  for (int i = 0; i < n; i++) {
    cin >> x;
    arr.push_back(x);
  }
  long long int steps = abs(arr[0]);
  for (int i = 1; i < n; i++) {
    steps += abs(arr[i] - arr[i - 1]);
  }
  cout << steps << endl;
  return 0;
}
