You are given 2 arrays a and b, both of size n. You can swap two elements in b at most once (or leave it as it is), and you are required to minimize the value $$$∑_{i}|a_{i}-b_{i}|.$$$

Find the minimum possible value of this sum.

Input

The first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ {10^9}). 

The third line contains n integers b_1, b_2, …, b_n (1 ≤ b_i ≤ {10^9}).

Output

Output the minimum value of ∑_{i}|a_{i}-b_{i}|.

Examples

Input


5
5 4 3 2 1
1 2 3 4 5


Output


4

Input


2
1 3
4 2


Output


2

Note

In the first example, we can swap the first and fifth element in array b, so that it becomes [ 5, 2, 3, 4, 1 ].

Therefore, the minimum possible value of this sum would be |5-5| + |4-2| + |3-3| + |2-4| + |1-1| = 4.

In the second example, we can swap the first and second elements. So, our answer would be 2.
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdlib>
#include <ctime>
#include <iostream>
#include <fstream>

/**
 *  This solution uses cpplib (prewritten code library)
 *  More info: https://github.com/agul/algolib/tree/master/cpplib
 */


#pragma comment(linker, "/STACK:66777216")
#pragma warning(disable : 4996)
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#pragma hdrstop












// todo[c++17]: replace with std::disjunction_v
template <bool... Bools>
struct Disjunction : std::false_type {};

template <bool First, bool... Others>
// todo[c++14] use bool_constant
struct Disjunction<First, Others...> : std::integral_constant<bool, First || Disjunction<Others...>::value> {};

#if __cplusplus >= 201703L
template <bool... Bools>
constexpr bool DisjunctionV = Disjunction<Bools...>::value;

static_assert(!DisjunctionV<>, "");
static_assert(!DisjunctionV<false, false>, "");
static_assert(DisjunctionV<true>, "");
static_assert(DisjunctionV<false, true>, "");
static_assert(DisjunctionV<true, false>, "");
static_assert(DisjunctionV<false, false, true, true>, "");
#endif


#include <iterator>


template<typename T>
constexpr auto has_begin(int) -> decltype(std::begin(std::declval<T>()), true) {
	return true;
}

template<typename T>
constexpr bool has_begin(...) {
	return false;
}

template <typename T>
using is_container = std::integral_constant<bool, has_begin<T>(0)>;






template <typename T, typename... Types>
// todo[c++17] use is_same_v
// todo[c++17] use variable template
using is_one_of = Disjunction<std::is_same<T, Types>::value...>;

//todo[c++14] use remove_cv_t
//todo[c++17] use is_integral_v
//todo[c++17] use  variable template
template <typename T>
using is_sane_integer = std::integral_constant<
		bool,
		std::is_integral<T>::value && !is_one_of<typename std::remove_cv<T>::type, char, signed char, unsigned char, bool, char16_t, char32_t, wchar_t>::value
>;


std::string to_string(const std::string& s) {
	return '"' + s + '"';
}

std::string to_string(const char* s) {
	return to_string(std::string(s));
}

std::string to_string(const char ch) {
	return {'\'', ch, '\''};
}

std::string to_string(const bool b) {
	return (b ? "true" : "false");
}

template<typename T, typename std::enable_if<Disjunction<is_sane_integer<T>::value, std::is_floating_point<T>::value>::value>::type* = nullptr>
std::string to_string(const T value) {
	return std::to_string(value);
}

template<typename A, typename B>
std::string to_string(const std::pair<A, B>&);

template<typename T, typename std::enable_if<is_container<T>::value>::type* = nullptr>
std::string to_string(const T& container) {
	bool is_first = true;
	std::string res = "{";
	for (const auto & x : container) {
		if (!is_first) {
			res += ", ";
		}
		is_first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

template<typename A, typename B>
std::string to_string(const std::pair<A, B>& p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

std::vector<std::string> vec_splitter(std::string s) {
	s += ',';
	std::vector<std::string> res;
	while (!s.empty()) {
		const size_t pos = s.find(',');
		res.emplace_back(s.substr(0, pos));
		s = s.substr(pos + 1);
	}
	return res;
}

void debug_out(
		std::vector<std::string> __attribute__ ((unused)) args,
		__attribute__ ((unused)) int idx,
		__attribute__ ((unused)) int LINE_NUM)
{
	std::cerr << std::endl;
}

template<typename Head, typename... Tail>
void debug_out(std::vector<std::string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	std::stringstream ss;
	ss << to_string(H);
	if (idx > 0) {
		std::cerr << ", ";
	} else {
		std::cerr << "Line(" << LINE_NUM << ") ";
	}
	const std::string& arg = args[idx];
	const std::string value = ss.str();
	if (arg == value) {
		std::cerr << arg;
	} else {
		std::cerr << arg << " = " << value;
	}
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef HOME
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif





namespace std {

template<typename T>
std::istream& operator>>(std::istream& in, std::vector<T>& vec) {
	for (auto& it : vec) {
		in >> it;
	}
	return in;
}


template<typename T, typename U>
std::istream& operator>>(std::istream& in, std::pair<T, U>& rhs) {
	in >> rhs.first >> rhs.second;
	return in;
}

}  // namespace std

void assign_files_input_txt() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}








#include <cstddef>


template<typename T>
class IntegerIterator : public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> {
public:
	using value_type = T;

	constexpr explicit IntegerIterator(const value_type value) : value_(value) {}

	IntegerIterator& operator++() {
		++value_;
		return *this;
	}

	IntegerIterator operator++(int) {
		IntegerIterator copy = *this;
		++value_;
		return copy;
	}

	IntegerIterator& operator--() {
		--value_;
		return *this;
	}

	IntegerIterator operator--(int) {
		IntegerIterator copy = *this;
		--value_;
		return copy;
	}

	constexpr value_type operator*() const {
		return value_;
	}

	constexpr bool operator ==(const IntegerIterator rhs) const {
		return value_ == rhs.value_;
	}

	constexpr bool operator !=(const IntegerIterator rhs) const {
		return !(*this == rhs);
	}

	constexpr value_type operator +(const IntegerIterator rhs) const {
		return value_ + rhs.value_;
	}

	IntegerIterator& operator +=(const IntegerIterator rhs) const {
		value_ += rhs.value_;
		return *this;
	}

	constexpr value_type operator -(const IntegerIterator rhs) const {
		return value_ - rhs.value_;
	}

	IntegerIterator& operator -=(const IntegerIterator rhs) const {
		value_ -= rhs.value_;
		return *this;
	}

private:
	value_type value_;
};


template<typename T>
class IntegerRange {
public:
	using const_iterator = IntegerIterator<T>;

	constexpr IntegerRange(const T begin, const T end) : begin_(begin), end_(end) {}

	constexpr const_iterator begin() const {
		return const_iterator(begin_);
	}

	constexpr const_iterator end() const {
		return const_iterator(end_);
	}

	constexpr T size() const {
		return end_ - begin_;
	}

private:
	T begin_;
	T end_;
};





template<typename T>
class ReversedRange {
public:
	using const_iterator = typename std::decay<T>::type::const_iterator;
	using reverse_iterator = std::reverse_iterator<const_iterator>;

	explicit constexpr ReversedRange(const T& iterable) : begin_(iterable.begin()), end_(iterable.end()) {}

	constexpr reverse_iterator begin() const {
		return reverse_iterator(end_);
	}

	constexpr reverse_iterator end() const {
		return reverse_iterator(begin_);
	}

private:
	const_iterator begin_;
	const_iterator end_;
};

template<typename T>
ReversedRange<T> reversed(T&& iterable) {
	return ReversedRange<T>{iterable};
}


template<typename T>
constexpr IntegerRange<T> range(const T to) {
	return IntegerRange<T>(0, to);
}

template<typename T>
constexpr IntegerRange<T> range(const T from, const T to) {
	return IntegerRange<T>(from, to);
}

template<typename T>
constexpr IntegerRange<T> inclusiveRange(const T to) {
	return IntegerRange<T>(0, to + 1);
}

template<typename T>
constexpr IntegerRange<T> inclusiveRange(const T from, const T to) {
	return IntegerRange<T>(from, to + 1);
}

template<typename T>
constexpr ReversedRange<IntegerRange<T>> downrange(const T from) {
	return reversed(range(from));
}

template<typename T>
constexpr ReversedRange<IntegerRange<T>> downrange(const T from, const T to) {
	return reversed(range(to, from));
}

template<typename T>
constexpr ReversedRange<IntegerRange<T>> inclusiveDownrange(const T from) {
	return reversed(range(from + 1));
}

template<typename T>
constexpr ReversedRange<IntegerRange<T>> inclusiveDownrange(const T from, const T to) {
	return reversed(range(to, from + 1));
}

template<typename R>
void sort(R& range) {
	std::sort(range.begin(), range.end());
}

template<typename R, typename Comp>
void sort(R& range, Comp comp) {
	std::sort(range.begin(), range.end(), comp);
}

template<typename R>
void reverse(R& range) {
	std::reverse(range.begin(), range.end());
}

template<typename R, typename T>
auto lower_bound(const R& range, const T& value) -> decltype(range.begin()) {
	return std::lower_bound(range.begin(), range.end(), value);
}

template<typename R, typename T, typename Comp>
auto lower_bound(const R& range, const T& value, Comp comp) -> decltype(range.begin()) {
	return std::lower_bound(range.begin(), range.end(), value, comp);
}

template<typename R, typename T>
auto upper_bound(const R& range, const T& value) -> decltype(range.begin()) {
	return std::upper_bound(range.begin(), range.end(), value);
}

template<typename R, typename T, typename Comp>
auto upper_bound(const R& range, const T& value, Comp comp) -> decltype(range.begin()) {
	return std::upper_bound(range.begin(), range.end(), value, comp);
}

template<typename R>
auto min_element(const R& range) -> decltype(range.begin()) {
	return std::min_element(range.begin(), range.end());
}

template<typename R>
auto max_element(const R& range) -> decltype(range.begin()) {
	return std::max_element(range.begin(), range.end());
}

template<typename R>
bool next_permutation(R& range) {
	return std::next_permutation(range.begin(), range.end());
}

template<typename T>
void unique(std::vector<T>& range) {
	range.erase(std::unique(range.begin(), range.end()), range.end());
}

template<typename T>
void dedup(std::vector<T>& range) {
	sort(range);
	unique(range);
}

template<typename R>
R sorted(R range) {
	sort(range);
	return range;
}

template<typename R, typename Comp>
R sorted(R range, Comp comp) {
	sort(range, comp);
	return range;
}



static constexpr long double PI = 3.14159265358979323846;
static constexpr long double EPS = 1e-9;
static constexpr int32_t INF = 0x3f3f3f3f;
static constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

static constexpr int32_t DX[8] = { -1, 0, 1, 0, -1, -1, 1, 1 };
static constexpr int32_t DY[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };

static constexpr uint32_t kDayMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

enum Direction : uint8_t {
	Up,
	Right,
	Down,
	Left,
	UpLeft,
	UpRight,
	DownRight,
	DownLeft,
	North = Up,
	East = Right,
	South = Down,
	West = Left,
	NorthWest = UpLeft,
	NorthEast = UpRight,
	SouthEast = DownRight,
	SouthWest = DownLeft,
	Unknown = 255
};


#include <cstdint>

















namespace Random {

inline std::chrono::system_clock::rep current_timestamp() {
	return std::chrono::system_clock::now().time_since_epoch().count();
}

inline uint64_t get_new_rand_seed() {
	return static_cast<uint64_t>(current_timestamp());
}

inline uint64_t get_rand_seed() {
	static const uint64_t kRandSeed = get_new_rand_seed();
	return kRandSeed;
}

using Engine = std::mt19937_64;

template<typename T>
using Distribution = std::uniform_int_distribution<T>;

inline Engine& random_engine() {
	static Engine engine(get_rand_seed());
	return engine;
}

template<typename T>
inline T get(const T to) {
	Distribution<T> distribution(0, to);
	return distribution(random_engine());
}

template<typename T>
inline T get(const T from, const T to) {
	return get(to - from) + from;
}

template<typename T = int32_t>
inline T get() {
	return get(static_cast<T>(0), std::numeric_limits<T>::max());
}

}  // namespace Random


template<typename T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
class SafeIntegralHash {
public:
	const T kRandomValue = static_cast<T>(Random::current_timestamp());

	T operator ()(const T& value) const {
		return value ^ kRandomValue;
	}
};

template<typename Key, typename Value, typename std::enable_if<std::is_integral<Key>::value>::type* = nullptr>
using SafeUnorderedMap = std::unordered_map<Key, Value, SafeIntegralHash<Key>>;

template<typename Key, typename Value, typename std::enable_if<std::is_integral<Key>::value>::type* = nullptr>
using SafeUnorderedMultiMap = std::unordered_multimap<Key, Value, SafeIntegralHash<Key>>;

template<typename Key, typename std::enable_if<std::is_integral<Key>::value>::type* = nullptr>
using SafeUnorderedSet = std::unordered_set<Key, SafeIntegralHash<Key>>;

template<typename Key, typename std::enable_if<std::is_integral<Key>::value>::type* = nullptr>
using SafeUnorderedMultiSet = std::unordered_multiset<Key, SafeIntegralHash<Key>>;





namespace std {

#ifndef STD_HASH_PAIR
template<typename T, typename U>
struct hash<std::pair<T, U>> {
	std::size_t operator()(const std::pair<T, U>& pair) const {
		return pair.first * 877117 + pair.second;
	}
};
#endif

}  // namespace std

















namespace safe {

template<typename T>
constexpr T abs(const T arg) {
	return arg < 0 ? -arg : arg;
}

template<typename T>
constexpr bool is_zero(const T arg) {
	return abs(arg) < EPS;
}

template<typename T>
constexpr bool equal(const T lhs, const T rhs) {
	return is_zero(lhs - rhs);
}

template<typename T>
constexpr bool not_equal(const T lhs, const T rhs) {
	return !equal(lhs, rhs);
}

template<typename T>
constexpr bool less_or_equal(const T lhs, const T rhs) {
	return lhs < rhs || equal(lhs, rhs);
}

template<typename T>
constexpr bool less(const T lhs, const T rhs) {
	return lhs < rhs && !equal(lhs, rhs);
}

template<typename T>
constexpr bool greater_or_equal(const T lhs, const T rhs) {
	return less_or_equal(rhs, lhs);
}

template<typename T>
constexpr bool greater(const T lhs, const T rhs) {
	return less(rhs, lhs);
}

template<typename T>
T sqrt(const T arg) {
	static_assert(std::is_floating_point<T>(), "Implemented only for floating point types.");
	if (is_zero(arg)) {
		return 0;
	}
	return std::sqrt(arg);
}

template<typename T>
T asin(const T arg) {
	static_assert(std::is_floating_point<T>(), "Implemented only for floating point types.");
	const T tmp_arg = std::min(static_cast<T>(1.0), std::max(static_cast<T>(-1.0), arg));
	return std::asin(tmp_arg);
}

template<typename T>
T acos(const T arg) {
	static_assert(std::is_floating_point<T>(), "Implemented only for floating point types.");
	const T tmp_arg = std::min(static_cast<T>(1.0), std::max(static_cast<T>(-1.0), arg));
	return std::acos(tmp_arg);
}

}

template<typename T = long double, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
class Decimal {
public:
    using value_type = T;

	/// caide keep
	constexpr Decimal() : Decimal(0) {}
	constexpr Decimal(const T value) : value_(value) {}

	Decimal& operator +=(const Decimal& rhs) {
		value_ += rhs.value_;
		return *this;
	}

	Decimal& operator -=(const Decimal& rhs) {
		value_ -= rhs.value_;
		return *this;
	}

	Decimal& operator *=(const Decimal& rhs) {
		value_ *= rhs.value_;
		return *this;
	}

	Decimal& operator /=(const Decimal& rhs) {
		value_ /= rhs.value_;
		return *this;
	}

	constexpr Decimal operator +(const Decimal& rhs) const {
		return{ value_ + rhs.value_ };
	}

	constexpr Decimal operator -(const Decimal& rhs) const {
		return{ value_ - rhs.value_ };
	}

	constexpr Decimal operator *(const Decimal& rhs) const {
		return{ value_ * rhs.value_ };
	}

	constexpr Decimal operator /(const Decimal& rhs) const {
		return{ value_ / rhs.value_ };
	}

	constexpr Decimal operator +() const {
		return{ value_ };
	}

	constexpr Decimal operator -() const {
		return negate();
	}

	constexpr Decimal negate() const {
		return{ -value_ };
	}

	constexpr Decimal abs() const {
		return{ safe::abs(value_) };
	}

	Decimal sin() const {
	    return {std::sin(value_)};
	}

	Decimal cos() const {
	    return {std::cos(value_)};
	}

    Decimal tan() const {
        return {std::tan(value_)};
    }

    Decimal atan() const {
        return {std::atan(value_)};
    }

	Decimal sqrt() const {
		return{ safe::sqrt(value_) };
	}

	Decimal asin() const {
		return{ safe::asin(value_) };
	}

	Decimal acos() const {
		return{ safe::acos(value_) };
	}

	Decimal pow(const Decimal arg) const {
		return{ std::pow(value_, arg.value()) };
	}

	Decimal log() const {
		return{ std::log(value_) };
	}

    Decimal exp() const {
        return{ std::exp(value_) };
    }

	constexpr bool operator ==(const Decimal& rhs) const {
		return safe::equal(value_, rhs.value_);
	}

	constexpr bool operator !=(const Decimal& rhs) const {
		return safe::not_equal(value_, rhs.value_);
	}

	constexpr bool operator <(const Decimal& rhs) const {
		return safe::less(value_, rhs.value_);
	}

	constexpr bool operator <=(const Decimal& rhs) const {
		return safe::less_or_equal(value_, rhs.value_);
	}

	constexpr bool operator >(const Decimal& rhs) const {
		return safe::greater(value_, rhs.value_);
	}

	constexpr bool operator >=(const Decimal& rhs) const {
		return safe::greater_or_equal(value_, rhs.value_);
	}

    constexpr explicit operator double() const {
        return static_cast<double>(value_);
    }

    constexpr explicit operator long double() const {
        return static_cast<long double>(value_);
    }

	constexpr value_type value() const {
		return value_;
	}

	constexpr value_type double_value() const {
		return value_;
	}

	[[nodiscard]] constexpr int int_value() const {
		return static_cast<int>(value_);
	}

	[[nodiscard]] constexpr long long long_value() const {
		return static_cast<long long>(value_);
	}

	constexpr Decimal frac() const {
		return{ value_ - long_value() };
	}

	Decimal ceil() const {
		if (safe::is_zero(frac())) {
			return{ value_ };
		}
		return{ long_value() + 1.0 };
	}

	constexpr Decimal floor() const {
		return{ static_cast<value_type>(long_value()) };
	}

	constexpr Decimal trunc() const {
		return floor();
	}

	constexpr Decimal round() const {
		return Decimal{value_ + 0.5}.floor();
	}

	[[nodiscard]] std::string str() const {
	    return std::to_string(value_);
	}

	static Decimal pi() {
		return{ PI };
	}

	static Decimal zero() {
		return{ 0 };
	}

	friend std::istream& operator >>(std::istream& in, Decimal& x) {
		in >> x.value_;
		return in;
	}

	friend std::ostream& operator <<(std::ostream& out, const Decimal& x) {
		out << x.value_;
		return out;
	}

private:
	value_type value_;
};

template<typename T>
std::string to_string(const Decimal<T> arg) {
    return arg.str();
}

namespace std {

template<typename T>
struct is_floating_point<Decimal<T>> : std::true_type {};

template<typename T>
Decimal<T> abs(const Decimal<T> arg) {
	return arg.abs();
}

template<typename T>
Decimal<T> sqrt(const Decimal<T> arg) {
	return arg.sqrt();
}

template<typename T>
Decimal<T> sin(const Decimal<T> arg) {
    return arg.sin();
}

template<typename T>
Decimal<T> cos(const Decimal<T> arg) {
    return arg.cos();
}

template<typename T>
Decimal<T> tan(const Decimal<T> arg) {
    return arg.tan();
}

template<typename T>
Decimal<T> atan(const Decimal<T> arg) {
    return arg.atan();
}

template<typename T>
Decimal<T> asin(const Decimal<T> arg) {
	return arg.asin();
}

template<typename T>
Decimal<T> acos(const Decimal<T> arg) {
	return arg.acos();
}

template<typename T>
Decimal<T> exp(const Decimal<T> arg) {
    return arg.exp();
}

template<typename T>
Decimal<T> pow(const Decimal<T> lhs, const Decimal<T> rhs) {
	return lhs.pow(rhs);
}

template<typename T>
Decimal<T> log(const Decimal<T> arg) {
	return arg.log();
}

template<typename T>
struct hash<Decimal<T>> {
	size_t operator()(const Decimal<T> arg) const {
		return hash<typename Decimal<T>::value_type>()(arg.value());
	}
};

}  // namespace std

template<typename T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
inline constexpr bool is_equal_to_zero(const T& a) {
	return std::abs(a) < EPS;
}

template<typename T, typename std::enable_if<!std::is_floating_point<T>::value>::type* = nullptr>
inline constexpr bool is_equal_to_zero(const T& a) {
	return a == 0;
}



template<typename T>
inline bool umin(T& a, const T& b) {
	return (b < a ? a = b, true : false);
}

template<typename T>
inline bool umax(T& a, const T& b) {
	return (a < b ? a = b, true : false);
}

template<typename T, size_t N>
struct MakeVector {
	template<typename... Args,
		typename R = std::vector<decltype(MakeVector<T, N - 1>::make_vector(std::declval<Args>()...)) >>
		static R make_vector(size_t first, Args... sizes) {
		auto inner = MakeVector<T, N - 1>::make_vector(sizes...);
		return R(first, inner);
	}
};

template<typename T>
struct MakeVector<T, 1> {
	/// caide keep
	template<typename R = std::vector<T>>
	static R make_vector(std::size_t size, const T& value) {
		return R(size, value);
	}
};

template<typename T, typename... Args>
auto make_vector(Args... args) -> decltype(MakeVector<T, sizeof...(Args)-1>::make_vector(args...)) {
	return MakeVector<T, sizeof...(Args)-1>::make_vector(args...);
}

template<typename T>
inline bool is_leap_year(const T year) {
	return year % 400 == 0 || (year % 100 != 0 && (year & 3) == 0);
}

inline size_t get_days_in_month(const size_t month, const size_t year) {
	return kDayMonth[month] + (month == 1 && is_leap_year(year) ? 1 : 0);
}

#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()





#ifdef _MSC_VER
#define LLD "%I64d"
#define LLU "%I64u"
#else
#define LLD "%lld"
#define LLU "%llu"
#endif

using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;

using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using pli = std::pair<ll, int>;

using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vp = std::vector<pii>;



class FZadachaObObmene {
public:
	static constexpr bool kWriteCaseNumber = false;
	static constexpr bool kMultiTest = false;
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        auto a = make_vector<int>(2, n, 0);
        in >> a;

        std::vector<int> min(n, INF), max(n, -INF);
        ll total = 0;
        for (int i : range(n)) {
            min[i] = std::min(a[0][i], a[1][i]);
            max[i] = std::max(a[0][i], a[1][i]);
            total += max[i] - min[i];
        }

        std::vector<std::tuple<int, int, int>> points;
        for (int i : range(2)) {
            for (int j : range(n)) {
                points.emplace_back(a[i][j], i, j);
            }
        }
        debug(total);
        sort(points);
        std::vector<std::multiset<int>> open(2);
        std::vector<bool> opened(n, false);
        ll max_overlap = 0;
        for (const auto& it : points) {
            int value, arr, pos;
            std::tie(value, arr, pos) = it;

            if (!opened[pos]) {
                open[arr].emplace(value);
                opened[pos] = true;
                continue;
            }
            const int cur_open = min[pos];
            open[arr ^ 1].erase(open[arr ^ 1].find(cur_open));

            const int best = (open[arr].empty() ? value : *open[arr].begin());
            // debug(value, cur_open, best);
            umax<ll>(max_overlap, value - std::max(cur_open, best));
        }
        out << total - 2 * max_overlap << std::endl;
	}


	FZadachaObObmene() {}


	static constexpr bool kUseCustomChecker = true;
	bool check(std::istringstream in, std::istringstream jury, std::istringstream out) {
        int n;
        in >> n;
        auto a = make_vector<int>(2, n, 0);
        in >> a;

        ll total = 0;
        for (int i : range(n)) {
            total += std::abs(a[0][i] - a[1][i]);
        }

        ll jans = total;
        for (int i : range(n)) {
            for (int j : range(i + 1, n)) {
                const ll cur_ans = total - std::abs(a[0][i] - a[1][i]) - std::abs(a[0][j] - a[1][j]) + std::abs(a[0][i] - a[1][j]) + std::abs(a[1][i] - a[0][j]);
                umin(jans, cur_ans);
            }
        }

        ll pans;
        out >> pans;

        if (jans != pans) {
            debug(jans, pans);
            return false;
        }

		return true;
	}


	static constexpr size_t kGeneratedTestsCount = 100;
	static constexpr bool kStopAfterFirstFail = true;
	static void generate_test(std::ostream& test) {
	    const int kMaxn = 3;
	    const int kMaxValue = 10;

	    const int n = Random::get(1, kMaxn);
	    test << n << std::endl;
	    for (int i : range(n)) {
	        test << Random::get(1, kMaxValue) << " ";
	    }
	    test << std::endl;
        for (int i : range(n)) {
            test << Random::get(1, kMaxValue) << " ";
        }
        test << std::endl;
	}

};


int main() {
	FZadachaObObmene solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);

	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	srand(time(nullptr));
	out << std::fixed << std::setprecision(16);
	if (FZadachaObObmene::kMultiTest) {
		size_t tests_count;
		in >> tests_count;
		for (size_t test_id : inclusiveRange<size_t>(1, tests_count)) {
			if (FZadachaObObmene::kWriteCaseNumber) {
				out << "Case #" << test_id << ": ";
			}
			solver.solve(in, out);
		}
	} else {
		solver.solve(in, out);
	}
	return 0;
}
