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