#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, c = 0, sum = 0, b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b;
    if (b != c) {
      c = b - c;
      sum += fabs(c);
    }
    c = b;
  }
  cout << sum;
  return 0;
}
