#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
vector<ll> z_algorithmll(const vector<ll> &s)
{
  vector<ll> prefix(s.size());
  for (int i = 1, j = 0; i < s.size(); i++)
  {
    if (i + prefix[i - j] < j + prefix[j])
    {
      prefix[i] = prefix[i - j];
    }
    else
    {
      int k = max(0LL, j + prefix[j] - i);
      while (i + k < s.size() && s[k] == s[i + k])
        ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int)s.size();
  return prefix;
}
int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
vector<ll> b(n);
rep(i, n){
  cin >> b[i];
}
vector<vector<ll>> v,vv;
rep(j,30){
  vector<ll> a1;
  vector<ll> a2;
  vector<ll> bb;
  rep(i,n){
    if(a[i]>>j & 1LL){a1.push_back(1);a2.push_back(0);}
    else {a1.push_back(0);a2.push_back(1);}
    if(b[i]>>j & 1LL)bb.push_back(1);
    else bb.push_back(0);
  }
  auto r=bb; r.push_back(-1);
  r.insert(r.end(), a1.begin(), a1.end());
  r.insert(r.end(), a1.begin(), a1.end());
  v.push_back(z_algorithmll(r));
  r=bb; r.push_back(-1);
  r.insert(r.end(), a2.begin(), a2.end());
  r.insert(r.end(), a2.begin(), a2.end());
  vv.push_back(z_algorithmll(r));
}
rep(i,n){
  bool ok=1;
  ll ans=0;
  rep(j,30){
    if(v[j][i+n+1]!=n&&vv[j][i+n+1]!=n){
      ok=0;
      break;
    }
    if(vv[j][i+n+1]==n)ans+=1LL<<j;
  }
  if(ok)cout << i << ' ' << ans <<endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

//ll mod = 1000000007;
ll mod = 998244353;

signed main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    bool is_minus_even = true;
    bool is_zero_exist = false;
    rep(i, n)
    {
        cin >> a[i];
        if (a[i] < 0)
        {
            is_minus_even = !is_minus_even;
        }
        if (a[i] == 0)
        {
            is_zero_exist = true;
        }
    }
    ll ans = 0;
    if (is_minus_even == true || (!is_minus_even && is_zero_exist))
    {
        rep(i, n)
        {
            ans += abs(a[i]);
        }
    }
    else
    {
        rep(i, n)
        {
            a[i] = abs(a[i]);
        }
        sort(all(a));
        ans = accumulate(a.begin() + 1, a.end(), 0LL) - a[0];
    }
    cout << ans << endl;
    return 0;
}