#include <bits/stdc++.h>
using namespace std;
long long arr[2000005], arr2[2000005], n, ans, as;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr2[i];
    if (arr2[i] != arr2[i - 1]) ans += abs(arr2[i] - arr2[i - 1]);
  }
  cout << ans << endl;
}
