#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long ans = 0, temp = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] > temp) {
      ans += (arr[i] - temp);
      temp = arr[i];
    } else if (temp == arr[i])
      continue;
    else {
      ans += (temp - arr[i]);
      temp = arr[i];
    }
  }
  cout << ans << "\n";
  return 0;
}
