#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, ans = 0, x, y = 0;
  cin >> n;
  while (n--) {
    cin >> x;
    if (x != y) {
      ans += abs(y - x);
      y = x;
    }
  }
  cout << ans;
  return 0;
}
