#include <bits/stdc++.h>
using namespace std;
template <typename T>
string tostr(const T& t) {
  ostringstream os;
  os << t;
  return os.str();
}
long long A[200010];
int main() {
  int n;
  cin >> n;
  for (int i = (int)(0); i <= (int)(n - 1); ++i) {
    cin >> A[i];
  }
  long long adder = 0;
  long long ret = 0;
  for (int i = (int)(0); i <= (int)(n - 1); ++i) {
    long long cur = adder;
    if (cur == A[i]) continue;
    if (A[i] > cur) {
      adder += (A[i] - cur);
      ret += A[i] - cur;
    } else {
      adder -= (cur - A[i]);
      ret += cur - A[i];
    }
  }
  cout << ret;
byebye:;
  return 0;
}
