#include <bits/stdc++.h>
using namespace std;
long long a[20000000];
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long rez = abs(a[0]);
  for (long long i = 1; i < n; i++) {
    rez += abs(a[i - 1] - a[i]);
  }
  cout << rez;
  return 0;
}
