#include <bits/stdc++.h>
using namespace std;
int main() {
  int b[200001];
  int n;
  long long steps = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> b[i];
  int rest = 0;
  for (int i = 1; i <= n; i++) {
    if (rest == b[i]) continue;
    steps += abs(rest - b[i]);
    rest = b[i];
  }
  cout << steps << endl;
}
