#include <bits/stdc++.h>
using namespace std;
int n = 0;
long long res = 0;
int A[500005], B[500005];
string s;
int main() {
  cin >> n;
  B[-1] = 0;
  for (int i = 0; i < n; i++) {
    cin >> B[i];
    if ((B[i] < 0 && B[i - 1] > 0) || (B[i] > 0 && B[i - 1] < 0))
      res += abs(B[i]) + abs(B[i - 1]);
    else
      res += abs(B[i] - B[i - 1]);
  }
  cout << res;
  return 0;
}
