#include <bits/stdc++.h>
using namespace std;
void fileIO() {}
bool sortbysecdesc(const pair<long long, long long> &a,
                   const pair<long long, long long> &b) {
  return a.second > b.second;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  fileIO();
  long long T;
  T = 1;
  while (T--) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (long long &x : a) {
      cin >> x;
    }
    long long moves = 0;
    long long curr = 0;
    for (long long x : a) {
      moves += abs(x - curr);
      curr = x;
    }
    cout << moves << "\n";
  }
  return 0;
}
