#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  long long int arr[n], res = 0, c = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    if (res < arr[i]) {
      c = c + arr[i] - res;
      res = arr[i];
    } else if (res > arr[i]) {
      c = c + res - arr[i];
      res = arr[i];
    }
  }
  cout << c << endl;
  return 0;
}
