#include <iostream>
#include <vector>
using namespace std;
#define int long long

signed main(){
	int N; cin >> N;
	vector<int> W(N);
	int S = 0;

	for (int i=0; i<N; i++){
		cin >> W[i];
		S += W[i];
	}

	if (S % 2 != 0){
		cout << 0;
	}
	else{
		int s_ = S/2; int n_ = N/2;

		vector<vector<int>> states;
		for (int i=0; i<n_+1; i++){
			vector<int> row(s_+1);
			states.push_back(row);
		}

		states[0][0] = 1;

		for (auto w: W){
			for (int y=n_; y>0; y--){
				for (int x=0; x<s_+1-w; x++){
					states[y][x+w] = (states[y][x+w] + states[y-1][x]) % 998244353;
				}
			}
		}

		vector<int> fact(1,1);
		for (int i=1; i<N+1; i++){
			fact.push_back( (fact[i-1] * i) % 998244353 );
		}

		int total = 0;
		for (int y=1; y<n_+1; y++){
			total = (total + (fact[y] * fact[N-y] % 998244353) * states[y][s_]) % 998244353;
		}

		total = (2 * total) % 998244353;

		if (N % 2 == 0){
			total = total - (fact[n_] * fact[n_] % 998244353) * states[n_][s_] % 998244353;
		}
		total = (total + 998244353) % 998244353;

		cout << total;
	}
}
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define rng(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); --i)
#define per(i, b) gnr(i, 0, b)
#define all(obj) begin(obj), end(obj)
#define allr(obj) rbegin(obj), rend(obj)
#define cinv(a) rep(i, (int)a.size()) cin >> a[i]
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<Pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;

template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, 1, 0, -1};
const int MOD =	1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const long double eps = 1e-10;
const char nl = '\n';

ll power(ll a, ll b) { return b ? power(a * a % MOD, b / 2) * (b % 2 ? a : 1) % MOD : 1; }

ll nCk(int n, int k)
{
	ll x = 1, y = 1;
	for (int i = 1; i <= k; ++i)
	{
		x = x * (n - i + 1) % MOD;
		y = y * i % MOD;
	}
	return x * power(y, MOD - 2) % MOD;
}

struct UF
{
	vi d;
	UF(int n) : d(n, -1) {}
	int root(int x)
	{
		if (d[x] < 0)
			return x;
		return d[x] = root(d[x]);
	}
	bool unite(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -d[root(x)]; }
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(20);	
	int n; cin >> n;	
	vi x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	int x_min1 = INF, x_min2 = INF, y_min1 = INF, y_min2 = INF;
	int x_max1 = 0, x_max2 = 0, y_max1 = 0, y_max2 = 0;
	int index_x_max1, index_x_min1, index_y_max1, index_y_min1;

	auto two_max = [&](int &max1, int &max2, int &index, vi &vec) -> void
	{
		rep(i, n)
		{
			if (max1 < vec[i])
			{
				max2 = max1;
				max1 = vec[i];
				index = i;
			}
			else if (max2 < vec[i])
			{
				max2 = vec[i];
			}
		}
	};
	two_max(x_max1, x_max2, index_x_max1, x);
	two_max(y_max1, y_max2, index_y_max1, y);

	auto two_min = [&](int &min1, int &min2, int &index, vi &vec) -> void
	{
		rep(i, n)
		{
			if (min1 > vec[i])
			{
				min2 = min1;
				min1 = vec[i];
				index = i;
			}
			else if (min2 > vec[i])
			{
				min2 = vec[i];
			}
		}
	};
	two_min(x_min1, x_min2, index_x_min1, x);
	two_min(y_min1, y_min2, index_y_min1, y);

	if (index_x_max1 == index_y_max1 && index_x_min1 == index_y_min1)
		cout << max(max(x_max1 - x_min2, x_max2 - x_min1), max(y_max1 - y_min2, y_max2 - y_min1)) << nl;
	else
	{
		vi ans;
		ans.pb(x_max1 - x_min1);
		ans.pb(y_max1 - y_min1);
		ans.pb(x_max1 - x_min2);
		ans.pb(y_max1 - y_min2);
		ans.pb(x_max2 - x_min1);
		ans.pb(y_max2 - y_min1);
		sort(allr(ans));
		cout << ans[1] << nl;
	}
}	
	
