#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  ;
  long long int i, j, k, n, no;
  cin >> n;
  vector<long long int> a;
  while (n--) {
    cin >> no;
    a.push_back(no);
  }
  long long int diff;
  long long int ans = 0;
  long long int prev = 0;
  for (i = 0; i < a.size(); i++) {
    diff = abs(a[i] - prev);
    ans += diff;
    prev = a[i];
  }
  cout << ans << endl;
  return 0;
}
