#include <bits/stdc++.h>
using namespace std;
long long int arr[200009] = {0}, tar[200009];
int main() {
  long long int n, i, j, ans = 0, d = 0, change = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> tar[i];
  for (i = 1; i <= n; i++) {
    arr[i] = arr[i] + change;
    d = tar[i] - arr[i];
    change = change + d;
    ans += abs(d);
  }
  cout << ans << endl;
  return 0;
}
