#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long cnt = 0;
  long long x = 0;
  long long arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) {
    if (x < arr[i]) {
      cnt += (arr[i] - x);
      x = arr[i];
    } else if (x > arr[i]) {
      cnt += (x - arr[i]);
      x = arr[i];
    }
  }
  cout << cnt;
  return 0;
}
