#include <bits/stdc++.h>
using namespace std;
long long n, m, k, l, v[1000009], ans, c[1000009];
int main() {
  cin >> n >> v[1];
  ans = abs(v[1]);
  for (int i = 2; i <= n; i++) cin >> v[i], ans += abs(v[i - 1] - v[i]);
  cout << ans;
}
