#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n;
  cin >> n;
  long long ans = 0, last = 0;
  for (long long(i) = (0); (i) < (n); (i)++) {
    long long x;
    cin >> x;
    if (i == 0)
      ans += llabs(x);
    else
      ans += llabs(x - last);
    last = x;
  }
  cout << ans << endl;
  return 0;
}
