#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> a1(n);
    vector<long long int> a2(n);
    for (long long int i = 0; i < n; i++) {
      cin >> a1[i];
    }
    for (long long int i = 0; i < n; i++) {
      cin >> a2[i];
    }
    long long int ans1 = *min_element(a1.begin(), a1.end());
    long long int ans2 = *min_element(a2.begin(), a2.end());
    for (long long int i = 0; i < n; i++) {
      a1[i] = a1[i] - ans1;
      a2[i] = a2[i] - ans2;
    }
    long long int sum = 0;
    for (long long int i = 0; i < n; i++) {
      sum += abs(a1[i] - a2[i]) + (min(a1[i], a2[i]) * 1);
    }
    cout << sum << endl;
  }
  return 0;
}
