#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a, b;
long long answer = 0;
int main(int argc, char* argv[]) {
  scanf("%d", &n);
  a.resize(n);
  b.resize(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  long long current_balance = 0;
  for (int i = 0; i < n; i++) {
    long long current_element = a[i] + current_balance;
    answer += abs(b[i] - current_element);
    current_balance += b[i] - current_element;
  }
  cout << answer << endl;
  return 0;
}
