#include <bits/stdc++.h>
using namespace std;
int a[200010];
int main() {
  int n;
  scanf("%d", &n);
  a[0] = 0;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 1; i <= n; ++i) {
    ans += abs(a[i] - a[i - 1]);
  }
  printf("%I64d\n", ans);
  return 0;
}
