#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int a[n], b[n];
    long long int sum = 0, suma = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      suma += b[i];
    }
    long long int mina = *min_element(a, a + n);
    long long int mine = *min_element(b, b + n);
    long long int ans = 0;
    for (int i = 0; i < n; i++) {
      ans += min(abs(a[i] - mina), abs(b[i] - mine));
      int aoeu = a[i];
      a[i] -= min(abs(a[i] - mina), abs(b[i] - mine));
      b[i] -= min(abs(aoeu - mina), abs(b[i] - mine));
      ans += abs(a[i] - mina);
      ans += abs(b[i] - mine);
    }
    cout << ans << "\n";
  }
}
