#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<array>
#include<queue>

namespace lib
{
	template<class T, class Comp>using p_queue = std::priority_queue<T, std::vector<T>, Comp>;

	template<std::uint64_t Mod>struct modnum;
	template<class T>constexpr T pow(T base, std::size_t p)
	{
		if (p == 0)
		{
			return T(1);
		}
		else if (p == 1)
		{
			return base;
		}
		else if (p == 2)
		{
			return base*base;
		}
		else if (p % 2 == 0)
		{
			return pow(pow(base, p / 2), 2);
		}
		else
		{
			return pow(pow(base, p / 2), 2)*base;
		}
	}
	template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod> const&);

	template<std::uint64_t Mod>struct modnum
	{
		static constexpr auto mod = Mod;
		std::uint64_t val;
		modnum() = default;
		constexpr modnum(std::uint64_t v) :val(v%Mod)
		{

		}

		constexpr modnum& operator+=(modnum const& v)
		{
			val += v.val;
			val %= mod;
			return *this;
		}
		constexpr modnum& operator-=(modnum const& v)
		{
			val += mod - v.val;
			val %= mod;
			return *this;
		}
		constexpr modnum& operator*=(modnum const& v)
		{
			val *= v.val;
			val %= mod;
			return *this;
		}
		constexpr modnum& operator/=(modnum const& v)
		{
			return operator*=(inverse(v));
		}
	};
	template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs += rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, int rhs)
	{
		return lhs += rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator+(int lhs, modnum<Mod> rhs)
	{
		return rhs += lhs;
	}
	template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs -= rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs *= rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, int rhs)
	{
		return lhs *= rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator*(int lhs, modnum<Mod> rhs)
	{
		return rhs *= lhs;
	}

	template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs /= rhs;
	}

	template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod>const& base)
	{
		return pow(base, Mod - 2);
	}

	template<class T>constexpr auto clamp(T v)
	{
		return std::max(v, T());
	}
	template<class T>void sort(std::vector<T>& vec)
	{
		std::sort(vec.begin(), vec.end());
	}
	template<class T, class Comp>void sort(std::vector<T>& vec, Comp&& comp)
	{
		std::sort(vec.begin(), vec.end(), std::forward<Comp>(comp));
	}

	template<class T>auto lower_bound(std::vector<T>const& vec, T v)
	{
		return std::distance(vec.begin(), std::lower_bound(vec.begin(), vec.end(), v));
	}
	template<class T>auto upper_bound(std::vector<T>const& vec, T v)
	{
		return std::distance(vec.begin(), std::upper_bound(vec.begin(), vec.end(), v));
	}

	struct scope_exit
	{
		std::function<void(void)> func;
		scope_exit(std::function<void(void)> f) :func(f)
		{

		}
		~scope_exit()
		{
			func();
		}
	};

	template<int val>using int_tag = std::integral_constant<int, val>;
}

void Main();
int main()	
{
	std::cin.tie(nullptr);
	std::cin.sync_with_stdio(false);
	Main();
}

void Main()
{
	int N;
	std::cin >> N;
	std::vector<std::int64_t> data(3 * N);
	for (auto& v : data)
	{
		std::cin >> v;
	}
	lib::p_queue<std::int64_t, std::greater<>> m;
	lib::p_queue<std::int64_t, std::less<>> u;
	std::int64_t ms = 0;
	std::int64_t us = 0;
	for (int i{}; i < N; ++i)
	{
		m.emplace(data[i]);
		u.emplace(data[2 * N + i]);
		ms += data[i];
		us += data[2 * N + i];
	}
	std::vector<std::int64_t> mt = { ms };
	std::vector<std::int64_t> ut = { us };
	for (int i{}; i < N; ++i)
	{
		ms -= m.top();
		m.pop();
		m.push(data[i + N]);
		ms += data[i + N];
		mt.emplace_back(std::max(mt.back(), ms));

		us -= u.top();
		u.pop();
		u.push(data[2 * N - i - 1]);
		us += data[2 * N - i - 1];
		ut.emplace_back(std::min(ut.back(), us));
	}
	std::int64_t max = std::numeric_limits<std::int64_t>::min();
	for (int i{}; i <= N; ++i)
	{
		max = std::max(max, mt[i] - ut[N - i]);
	}
	std::cout << max << std::endl;
}

Measured memory_bytes: 6636