#include <bits/stdc++.h>
using namespace std;
long long a[200010];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long cnt = 0, flag = 0;
  for (int i = 1; i <= n; i++) {
    cnt += abs(a[i] - flag);
    flag = a[i];
  }
  cout << cnt << endl;
}
