#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int A[N];
int main() {
  int n;
  long long ans = 0, cntr = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++) {
    if (A[i] >= cntr)
      ans += (A[i] - cntr), cntr = A[i];
    else
      ans += (cntr - A[i]), cntr = A[i];
  }
  cout << ans << endl;
}
