#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void solve() {
  long long N;
  cin >> N;
  long long arr[N];
  long long mina = INT_MAX, minb = INT_MAX;
  long long moves = 0;
  long long arr2[N];
  for (long long i = 0; i < N; i++) {
    cin >> arr[i];
    if (arr[i] < mina) {
      mina = arr[i];
    }
  }
  for (long long i = 0; i < N; i++) {
    cin >> arr2[i];
    if (arr2[i] < minb) {
      minb = arr2[i];
    }
  }
  for (long long i = 0; i < N; i++) {
    if (arr[i] - mina < arr2[i] - minb) {
      moves += arr[i] - mina;
      arr2[i] -= arr[i] - mina;
      moves += arr2[i] - minb;
    } else {
      moves += arr2[i] - minb;
      arr[i] -= arr2[i] - minb;
      moves += arr[i] - mina;
    }
  }
  cout << moves << '\n';
}
signed main() {
  fast();
  long long t = 1;
  cin >> t;
  while (t--) solve();
}
