#include <bits/stdc++.h>
long long cmpfunc(const void* a, const void* b) {
  return (*(long long*)a - *(long long*)b);
}
int main(void) {
  long long int test, i, j, n, flag = 0, o1 = 0, o2 = 0, b1, x[1000000] = {0},
                               m, l, max, x1, y1, sum2, min, k, f, r, o, sum,
                               count = 0, a[1000000] = {0}, flag1 = 0;
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  sum = 0;
  for (i = 0; i < n; i++) {
    if (i > 0) {
      sum += abs(a[i] - a[i - 1]);
    } else {
      sum += abs(a[i]);
    }
  }
  printf("%lld\n", sum);
  return 0;
}
