#include<iostream>
#include<cstdio>
using namespace std;
const int N = 100010;
int n;
int b[N];
int main()
{
scanf("%d", &n);
for(int i = 1;i <= n;i ++) scanf("%d", &b[i]);
for(int i = 1;i <= n;i ++)
{
int x;
scanf("%d", &x);
b[i] -= x;
}
for(int i = n;i ;i --) b[i] -= b[i - 1]; // 由原数组处理出差分数组
int pos = 0, neg = 0;
for(int i = 1;i <= n;i ++)
{
if(b[i] > 0) pos += b[i];
else neg -= b[i];
}
printf("%d\n", max(pos, neg));
return 0;
}
//这里填你的代码^^
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~