#include <bits/stdc++.h>
using namespace std;
long long INV2 = 500000004;
long long INV6 = 166666668;
long long power(long long a, long long b, long long c) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b & 1) x = (x * y) % c;
    y = (y * y) % c;
    b /= 2;
  }
  return x % c;
}
int dx[] = {0, -1, 0, 1};
int dy[] = {-1, 0, 1, 0};
int dr[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dc[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int N = 2e5 + 5;
long long a[N];
int main() {
  int n;
  scanf("%d", &n);
  long long mn = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    mn = min(mn, a[i]);
  }
  long long ans = 0, cnt = 0;
  for (int i = 1; i <= n; ++i) {
    ans += abs(cnt - a[i]);
    cnt = a[i];
  }
  printf("%lld\n", ans);
  return 0;
}
