#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const long long MOD = 1e9 + 7;
const double eps = 0.0000001;
int n;
long long a[2 * N], res;
int main() {
  cin >> n;
  for (int i = (1); i <= (n); i++) cin >> a[i];
  long long x = 0;
  for (int i = (1); i <= (n); i++)
    if (x < a[i]) {
      res += a[i] - x;
      x = a[i];
    } else if (x > a[i]) {
      res += x - a[i];
      x = a[i];
    }
  cout << res;
  return 0;
}
