#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, b = 0;
  long long m = 0;
  vector<int> v;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &t);
    m += abs(t - b);
    b = t;
  }
  printf("%I64d\n", m);
}
