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