#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long sum = 0;
  long long now = 0;
  for (int i = 0; i < n; ++i) {
    sum += abs(a[i] - now);
    now += a[i] - now;
  }
  cout << sum << endl;
  return 0;
}
