#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, i, a, m;
  long long z = 0, k = 0;
  cin >> n;
  long int *arr2 = new (long int[n]);
  for (int i = 0; i < n; i++) cin >> arr2[i];
  for (i = 0; i < n; i++) {
    a = arr2[i] + z;
    z = z - a;
    k = k + abs(a);
  }
  cout << k;
}
