#include <bits/stdc++.h>
void B() {
  int n, i, b[200001];
  long long unsigned s = 0;
  scanf("%i", &n);
  for (i = 0; i < n; ++i) scanf("%i", &b[i]);
  for (i = 0; i < n; ++i) {
    if (i == 0)
      s += (((b[0]) < (-b[0])) ? (-b[0]) : (b[0]));
    else {
      int p = b[i] - b[i - 1];
      s += (((p) < (-p)) ? (-p) : (p));
    }
  }
  printf("%I64d", s);
}
int main() {
  B();
  return 0;
}
