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

#define endl '\n'
#define f first
#define s second
#define ll long long
#define lli long long int
#define pf push_front
#define pb push_back
const int mod = 1e9 +7, INF = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;

        vector <int> v(n);
        for (auto &i : v) cin >> i;

        if (n & 1) {
            v.pb(v[0]), v.pb(v[1]);
            for (int i = 2; i < v.size(); ++i) cout << v[i] << " ";
            cout << endl;
        }
        else {
            for (int i = 0; i < n-1; ++i) {
                swap(v[i], v[i+1]);
                ++i;
            }

            for (auto i : v) cout << i << " ";
            cout << endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::snyc_with_stdio(false);
    cin.tie(NULL);
    long t;cin>>t;
    while(t--)
    {
        long n;cin>>n;
        vector<long>a(n);
        for(int i=0;i<n;i++)
        cin>>a[i];
        for(int i=a.size()-1;i>=0;i--)
        {
            cout<<a[i]<<" ";
        }
        cout<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   // ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    long t;cin>>t;
    while(t--)
    {
        long n;cin>>n;
        vector<long>a(n);
        for(int i=0;i<n;i++)
        cin>>a[i];
        for(int i=a.size()-1;i>=0;i--)
        {
            cout<<a[i]<<" ";
        }
        cout<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long t;cin>>t;
    while(t--)
    {
        long n;cin>>n;
        vector<long>a(n);
        for(int i=0;i<n;i++)
        cin>>a[i];
        for(int i=a.size()-1;i>=0;i--)
        {
            cout<<a[i]<<" ";
        }
        cout<<"\n";
    }
}


#include<bits/stdc++.h>
using namesace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long t;cin>>t;
    while(t--)
    {
        long n;cin>>n;
        vector<long>a(n);
        for(int i=0;i<n;i++)
        cin>>a[i];
        for(int i=a.size()-1;i>=0;i--)
        {
            cout<<a[i]<<" ";
        }
        cout<<"\n";
    }
}


/***
  *  بسم الله الرحمن الرحيم
  *
  * author : Ahmed al mohammed
  *
***/

#import "bits/stdc++.h"
#define P push
#define F first
#define S second
#define pb push_back
typedef long long ll;
#define pf push_front
#define PQ priority_queue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define  lp(a,x) (lower_bound(a.begin(),a.end(),x)-a.begin())
#define  up(a,x) (upper_bound(a.begin(),a.end(),x)-a.begin())
#define hurry ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

ll pw(ll x ,ll os)
{
    if(os==0)return 1;
    ll z=pw(x,os/2);
    if(os%2)return z*z*x;
    else return z*z;
}

void sieve(){
    ll n=1e6;
    bool a[n+2]={};
    for(int i=2;i*i<=n;i++){
         if(!a[i])
        for(int j=i*i;j<=n;j+=i){
            a[j]=1;
        }
    }
    for(int i=2;i<=n;i++){
        if(a[i]^1)cout<<i<<" ";
    }
}

long long Cnr(long long n,long long r){
    r=min(r,n-r);
    long long ans=1;
    for(long long i=1 ; i<=r ; i++){
        ans*=(n--);
        ans/=i;
    }
    return ans;
}

bool isprime(ll x){
for(ll i=2;i*i<=x;i++){
    if((x%i)==0)return false;
}
return true;
}
ll a[505050],b[505050];
void run_case() {
 int n;cin>>n;
 for(int i=0;i<n;i++)
    cin>>a[i];
 for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";cout<<"\n";
}
int main(){
    hurry
    int tests=1;
    cin>>tests;
    while(tests--)
         run_case();

    return 0;
}


/***
  *  بسم الله الرحمن الرحيم
  *
  * author : Ahmed al mohammed
  *
***/

#import "bits/stdc++.h"
#define P push
#define F first
#define S second
#define pb push_back
typedef long long ll;
#define pf push_front
#define PQ priority_queue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define  lp(a,x) (lower_bound(a.begin(),a.end(),x)-a.begin())
#define  up(a,x) (upper_bound(a.begin(),a.end(),x)-a.begin())
#define hurry ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

ll pw(ll x ,ll os)
{
    if(os==0)return 1;
    ll z=pw(x,os/2);
    if(os%2)return z*z*x;
    else return z*z;
}

void sieve(){
    ll n=1e6;
    bool a[n+2]={};
    for(int i=2;i*i<=n;i++){
         if(!a[i])
        for(int j=i*i;j<=n;j+=i){
            a[j]=1;
        }
    }
    for(int i=2;i<=n;i++){
        if(a[i]^1)cout<<i<<" ";
    }
}

long long Cnr(long long n,long long r){
    r=min(r,n-r);
    long long ans=1;
    for(long long i=1 ; i<=r ; i++){
        ans*=(n--);
        ans/=i;
    }
    return ans;
}

bool isprime(ll x){
for(ll i=2;i*i<=x;i++){
    if((x%i)==0)return false;
}
return true;
}
ll a[505050],b[505050];
void run_case() {
 int n;cin>>n;
 for(int i=0;i<n;i++)cin>>a[i];
 if(n%2==0)
    for(int i=0;i+1<n;i+=2)cout<<a[i+1]<<" "<<a[i]<<" ";

 else {
    cout<<a[n/2]<<" ";
    for(int i=n-1;i-1>(n/2);i-=2){
        cout<<a[i-1]<<" "<<a[i]<<" ";
    }
    for(int i=n/2-1;i-1>=0;i-=2)
          cout<<a[i-1]<<" "<<a[i]<<" ";
 }
 cout<<"\n";
}
int main(){
    hurry
    int tests=1;
    cin>>tests;
    while(tests--)
         run_case();

    return 0;
}


/***
  *  بسم الله الرحمن الرحيم
  *
  * author : Ahmed al mohammed
  *
***/

#import "bits/stdc++.h"
#define P push
#define F first
#define S second
#define pb push_back
typedef long long ll;
#define pf push_front
#define PQ priority_queue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define  lp(a,x) (lower_bound(a.begin(),a.end(),x)-a.begin())
#define  up(a,x) (upper_bound(a.begin(),a.end(),x)-a.begin())
#define hurry ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

ll pw(ll x ,ll os)
{
    if(os==0)return 1;
    ll z=pw(x,os/2);
    if(os%2)return z*z*x;
    else return z*z;
}

void sieve(){
    ll n=1e6;
    bool a[n+2]={};
    for(int i=2;i*i<=n;i++){
         if(!a[i])
        for(int j=i*i;j<=n;j+=i){
            a[j]=1;
        }
    }
    for(int i=2;i<=n;i++){
        if(a[i]^1)cout<<i<<" ";
    }
}

long long Cnr(long long n,long long r){
    r=min(r,n-r);
    long long ans=1;
    for(long long i=1 ; i<=r ; i++){
        ans*=(n--);
        ans/=i;
    }
    return ans;
}

bool isprime(ll x){
for(ll i=2;i*i<=x;i++){
    if((x%i)==0)return false;
}
return true;
}
ll a[505050],b[505050];
void run_case() {
 int n;cin>>n;
 for(int i=0;i<n;i++)
    cin>>a[i];
 for(int i=n-1;i>=0;i--)cout<<a[i];
}
int main(){
    hurry
    int tests=1;
    cin>>tests;
    while(tests--)
         run_case();

    return 0;
}


/***
  *  بسم الله الرحمن الرحيم
  *
  * author : Ahmed al mohammed
  *
***/

#import "bits/stdc++.h"
#define P push
#define F first
#define S second
#define pb push_back
typedef long long ll;
#define pf push_front
#define PQ priority_queue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define  lp(a,x) (lower_bound(a.begin(),a.end(),x)-a.begin())
#define  up(a,x) (upper_bound(a.begin(),a.end(),x)-a.begin())
#define hurry ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

ll pw(ll x ,ll os)
{
    if(os==0)return 1;
    ll z=pw(x,os/2);
    if(os%2)return z*z*x;
    else return z*z;
}

void sieve(){
    ll n=1e6;
    bool a[n+2]={};
    for(int i=2;i*i<=n;i++){
         if(!a[i])
        for(int j=i*i;j<=n;j+=i){
            a[j]=1;
        }
    }
    for(int i=2;i<=n;i++){
        if(a[i]^1)cout<<i<<" ";
    }
}

long long Cnr(long long n,long long r){
    r=min(r,n-r);
    long long ans=1;
    for(long long i=1 ; i<=r ; i++){
        ans*=(n--);
        ans/=i;
    }
    return ans;
}

bool isprime(ll x){
for(ll i=2;i*i<=x;i++){
    if((x%i)==0)return false;
}
return true;
}
ll a[505050],b[505050];
void run_case() {
 int n;cin>>n;
 for(int i=1;i<=n;i++)cin>>a[i];
 swap(a[1],a[n]);
 for(int i=1;i<=n;i++)cout<<a[i]<<" ";
 cout<<"\n";

}
int main(){
    hurry
    int tests=1;
    cin>>tests;
    while(tests--)
         run_case();

    return 0;
}


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

void solve()
{
    int  n;
    cin>> n;
    vector<int>a( n);
    for(auto &it: a)
    {
        cin>>it;
    }
    int num= a.size();
    int s = 0;
    int e =  num-1;
    if(num%2 == 0)
    {
        for(int i=0;i<num;i = i + 2)
        {
            swap(a[i], a[i+1]);
        }
    }
    else
    {
        int mid = (s + e)/2;
        while(s<mid-1)
        {
            swap(a[s],a[mid-1]);
            s++;
            mid--;

        }
        s = 0;
        e = num - 1;
        mid = (s+e)/2;
        while(mid<e)
        {
            swap(a[mid],a[e]);
            mid++;
            e--;
        }
        s = 0;
        e = num - 1;
        while(s<e)
        {
            swap(a[s],a[e]);
            s++;
            e--;
        }
    }
    for(int i=0;i< n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
void solve()
{
    int n;
    cin>>n;
    vector<int>a(n);
    for(auto &it: a)
    {
        cin>>it;
    }
    int i,j;
    int maxele = *max_element(a.begin(),a.end());
    int minele = *min_element(a.begin(),a.end());
    while(maxele != minele)
    {

    }

}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

void solve()
{
    int  n;
    cin>> n;
    vector<int>a( n);
    for(auto &it: a)
    {
        cin>>it;
    }
    int num= a.size();
    int s = 0;
    int e =  num-1;
    for(int i=0;i<num;i = i + 2)
    {
        if( num % 2 == 0)
        {
            swap(a[i], a[i+1]);
        }
        else
        {
           break;
        }

    }

    if(num%2 != 0)
    {
        int mid = (s + e)/2;
        while(s<mid-1)
        {
            swap(a[s],a[mid-1]);
            s++;
            mid--;

        }
        s = 0;
        e = num - 1;
        mid = (s+e)/2;
        while(mid<e)
        {
            swap(a[mid],a[e]);
            mid++;
            e--;
        }
        s = 0;
        e = num - 1;
        while(s<e)
        {
            swap(a[s],a[e]);
            s++;
            e--;
        }
    }
    for(int i=0;i< n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
void solve()
{
    int  n;
    cin>> n;
    vector<int>a( n);
    for(auto &it: a)
    {
        cin>>it;
    }
    int num= a.size();
    int s = 0;
    int e =  num-1;
    for(int i=0;i<num;i = i + 2)
    {
        if( num % 2 == 0)
        {
            swap(a[i], a[i+1]);
        }
        else
        {
            while(s<e)
            {
                swap(a[s], a[e]);
                s++;
                e--;
            }
        }

    }
    for(int i=0;i< num;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


// Wrong Logic
// #include<bits/stdc++.h>
// using namespace std;

// void solve()
// {
//     int  n;
//     cin>> n;
//     vector<int>a( n);
//     for(auto &it: a)
//     {
//         cin>>it;
//     }
//     int num= a.size();
//     int s = 0;
//     int e =  num-1;
//     if(num%2 == 0)
//     {
//         for(int i=0;i<num;i = i + 2)
//         {
//             swap(a[i], a[i+1]);
//         }
//     }
//     else
//     {
//         int mid = (s + e)/2;
//         while(s<mid-1)
//         {
//             swap(a[s],a[mid-1]);
//             s++;
//             mid--;

//         }
//         s = 0;
//         e = num - 1;
//         mid = (s+e)/2;
//         while(mid<e)
//         {
//             swap(a[mid],a[e]);
//             mid++;
//             e--;
//         }
//         s = 0;
//         e = num - 1;
//         while(s<e)
//         {
//             swap(a[s],a[e]);
//             s++;
//             e--;
//         }
//     }
//     for(int i=0;i< n;i++)
//     {
//         cout<<a[i]<<" ";
//     }
//     cout<<endl;
// }
// int main()
// {
//     int t;
//     cin>>t;
//     while(t--)
//     {
//         solve();
//     }
//     return 0;
// }

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

void solve()
{
    int  n;
    cin>> n;
    vector<int>a( n);
    for(auto &it: a)
    {
        cin>>it;
    }
    int num= a.size();
    int s = 0;
    int e =  num-1;
    while(s<e)
    {
        swap(a[s],a[e]);
        s++;
        e--;
    }

    for(int i=0;i< n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
int factorial(int n);
int factorial(int n)
{
    if(n==1)
    {
        return 1;
    }
    else
    {
        return n*factorial(n-1);
    }

}

bool is_prime(ll n) {
    // Assumes that n is a positive natural number
    // We know 1 is not a prime number
    if (n == 1) {
        return false;
    }

    ll i = 2;
    // This will loop from 2 to int(sqrt(x))
    while (i*i <= n) {
        // Check if i divides x without leaving a remainder
        if (n % i == 0) {
            // This means that n has a factor in between 2 and sqrt(n)
            // So it is not a prime number
            return false;
        }
        i += 1;
    }
    // If we did not find any factor in the above loop,
    // then n is a prime number
    return true;
}
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
typedef unsigned long long  ull;

int check(int x,vector <int> a,int n)
{  int county=0;
  map <int,int> mapa;
    for(int i=0;i<n;i++)
    {
        mapa.insert(pair<int,int>(a[i],0));
    }
    for(int i=0;i<n;i++)
    {
        mapa[a[i]]++;
    }
   // cout<<mapa[1]<<mapa[2]<<mapa[3]<<mapa[4]<<mapa[5]<<endl;
    for(int i=0;i<a.size();i++)
    {   mapa[a[i]]--;
        if(mapa[abs(a[i]-x)]>0)
        {
            county++;

            mapa[abs(a[i]-x)]--;
        }

    }
    return county;
}

typedef unsigned int ui;

int main()
{  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

 int t;
 cin>>t;
 while(t>0)
 {
    int n;
    cin>>n;
  vector <int> a(n);
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  vector <int> suma(n-1);
  for(int i=0;i<n-1;i++)
  {
      suma[i]=a[i+1]+a[i];
  }
  sort(suma.begin(),suma.end());
  next_permutation(a.begin(),a.end());
   int fact=factorial(n);
   fact--;
   while(fact!=0)
   {
         vector <int> sumb(n-1);
  for(int i=0;i<n-1;i++)
  {
      sumb[i]=a[i+1]+a[i];
  }
  sort(sumb.begin(),sumb.end());
        if(suma==sumb)
        {
            break;
        }

       next_permutation(a.begin(),a.end());
       fact--;
   }
   for(int i=0;i<n;i++)
   {
       cout<<a[i]<<" ";
   }
   cout<<endl;

     t--;
 }

}


#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
int factorial(int n);
int factorial(int n)
{
    if(n==1)
    {
        return 1;
    }
    else
    {
        return n*factorial(n-1);
    }

}

bool is_prime(ll n) {
    // Assumes that n is a positive natural number
    // We know 1 is not a prime number
    if (n == 1) {
        return false;
    }

    ll i = 2;
    // This will loop from 2 to int(sqrt(x))
    while (i*i <= n) {
        // Check if i divides x without leaving a remainder
        if (n % i == 0) {
            // This means that n has a factor in between 2 and sqrt(n)
            // So it is not a prime number
            return false;
        }
        i += 1;
    }
    // If we did not find any factor in the above loop,
    // then n is a prime number
    return true;
}
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
typedef unsigned long long  ull;

int check(int x,vector <int> a,int n)
{  int county=0;
  map <int,int> mapa;
    for(int i=0;i<n;i++)
    {
        mapa.insert(pair<int,int>(a[i],0));
    }
    for(int i=0;i<n;i++)
    {
        mapa[a[i]]++;
    }
   // cout<<mapa[1]<<mapa[2]<<mapa[3]<<mapa[4]<<mapa[5]<<endl;
    for(int i=0;i<a.size();i++)
    {   mapa[a[i]]--;
        if(mapa[abs(a[i]-x)]>0)
        {
            county++;

            mapa[abs(a[i]-x)]--;
        }

    }
    return county;
}

typedef unsigned int ui;

int main()
{  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

 int t;
 cin>>t;
 while(t>0)
 {
    int n;
    cin>>n;
  vector <int> a(n);
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  next_permutation(a.begin(),a.end());
   for(int i=0;i<n;i++)
   {
       cout<<a[i]<<" ";
   }
   cout<<endl;

     t--;
 }

}


#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
int factorial(int n);
int factorial(int n)
{
    if(n==1)
    {
        return 1;
    }
    else
    {
        return n*factorial(n-1);
    }

}

bool is_prime(ll n) {
    // Assumes that n is a positive natural number
    // We know 1 is not a prime number
    if (n == 1) {
        return false;
    }

    ll i = 2;
    // This will loop from 2 to int(sqrt(x))
    while (i*i <= n) {
        // Check if i divides x without leaving a remainder
        if (n % i == 0) {
            // This means that n has a factor in between 2 and sqrt(n)
            // So it is not a prime number
            return false;
        }
        i += 1;
    }
    // If we did not find any factor in the above loop,
    // then n is a prime number
    return true;
}
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
typedef unsigned long long  ull;

int check(int x,vector <int> a,int n)
{  int county=0;
  map <int,int> mapa;
    for(int i=0;i<n;i++)
    {
        mapa.insert(pair<int,int>(a[i],0));
    }
    for(int i=0;i<n;i++)
    {
        mapa[a[i]]++;
    }
   // cout<<mapa[1]<<mapa[2]<<mapa[3]<<mapa[4]<<mapa[5]<<endl;
    for(int i=0;i<a.size();i++)
    {   mapa[a[i]]--;
        if(mapa[abs(a[i]-x)]>0)
        {
            county++;

            mapa[abs(a[i]-x)]--;
        }

    }
    return county;
}

typedef unsigned int ui;

int main()
{  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

 int t;
 cin>>t;
 while(t>0)
 {
    int n;
    cin>>n;
  vector <int> a(n);
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }

   for(int i=0;i<n;i++)
   {
       cout<<a[i]<<" ";
   }
   cout<<endl;

     t--;
 }

}


#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
int factorial(int n);
int factorial(int n)
{
    if(n==1)
    {
        return 1;
    }
    else
    {
        return n*factorial(n-1);
    }

}

bool is_prime(ll n) {
    // Assumes that n is a positive natural number
    // We know 1 is not a prime number
    if (n == 1) {
        return false;
    }

    ll i = 2;
    // This will loop from 2 to int(sqrt(x))
    while (i*i <= n) {
        // Check if i divides x without leaving a remainder
        if (n % i == 0) {
            // This means that n has a factor in between 2 and sqrt(n)
            // So it is not a prime number
            return false;
        }
        i += 1;
    }
    // If we did not find any factor in the above loop,
    // then n is a prime number
    return true;
}
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
typedef unsigned long long  ull;

int check(int x,vector <int> a,int n)
{  int county=0;
  map <int,int> mapa;
    for(int i=0;i<n;i++)
    {
        mapa.insert(pair<int,int>(a[i],0));
    }
    for(int i=0;i<n;i++)
    {
        mapa[a[i]]++;
    }
   // cout<<mapa[1]<<mapa[2]<<mapa[3]<<mapa[4]<<mapa[5]<<endl;
    for(int i=0;i<a.size();i++)
    {   mapa[a[i]]--;
        if(mapa[abs(a[i]-x)]>0)
        {
            county++;

            mapa[abs(a[i]-x)]--;
        }

    }
    return county;
}

typedef unsigned int ui;

int main()
{  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

 int t;
 cin>>t;
 while(t>0)
 {
    int n;
    cin>>n;
  vector <int> a(n);
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  reverse(a.begin(),a.end());
   for(int i=0;i<n;i++)
   {
       cout<<a[i]<<" ";
   }
   cout<<endl;

     t--;
 }

}


#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
int factorial(int n);
int factorial(int n)
{
    if(n==1)
    {
        return 1;
    }
    else
    {
        return n*factorial(n-1);
    }

}

bool is_prime(ll n) {
    // Assumes that n is a positive natural number
    // We know 1 is not a prime number
    if (n == 1) {
        return false;
    }

    ll i = 2;
    // This will loop from 2 to int(sqrt(x))
    while (i*i <= n) {
        // Check if i divides x without leaving a remainder
        if (n % i == 0) {
            // This means that n has a factor in between 2 and sqrt(n)
            // So it is not a prime number
            return false;
        }
        i += 1;
    }
    // If we did not find any factor in the above loop,
    // then n is a prime number
    return true;
}
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
typedef unsigned long long  ull;

int check(int x,vector <int> a,int n)
{  int county=0;
  map <int,int> mapa;
    for(int i=0;i<n;i++)
    {
        mapa.insert(pair<int,int>(a[i],0));
    }
    for(int i=0;i<n;i++)
    {
        mapa[a[i]]++;
    }
   // cout<<mapa[1]<<mapa[2]<<mapa[3]<<mapa[4]<<mapa[5]<<endl;
    for(int i=0;i<a.size();i++)
    {   mapa[a[i]]--;
        if(mapa[abs(a[i]-x)]>0)
        {
            county++;

            mapa[abs(a[i]-x)]--;
        }

    }
    return county;
}

typedef unsigned int ui;

int main()
{  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

 int t;
 cin>>t;
 while(t>0)
 {
    int n;
    cin>>n;
  vector <int> a(n);
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  int temp=a[0];
  a[0]=a[n-1];
  a[n-1]=temp;
   for(int i=0;i<n;i++)
   {
       cout<<a[i]<<" ";
   }
   cout<<endl;

     t--;
 }

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
	ll t;
	cin>>t;
	while(t--){
	ll n;
	cin>>n;
	vector <ll> v(n),v2(n);
	for(int i=0;i<v.size();i++)
		cin>>v[i];
	for(int i=0;i<n-1;i++)
		v2[i]=v[i+1];

	v2[n-1]=v[0];

	for(int i=0;i<v.size();i++)
		cout<<v2[i]<<" ";
	cout<<"\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
	ll t;
	cin>>t;
	while(t--){
	ll n;
	cin>>n;
	vector <ll> v(n);
	for(int i=0;i<v.size();i++)
		cin>>v[i];
	swap(v[0],v[1]);
	for(int i=0;i<v.size();i++)
		cout<<v[i]<<" ";
	cout<<"\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
	ll t;
	cin>>t;
	while(t--){
	ll n;
	cin>>n;
	vector <ll> v(n),v2(n);
	for(int i=0;i<v.size();i++)
		cin>>v[i];

	if(n%2==0){
		for(int i=0;i<v.size();i+=2)
			cout<<v[i+1]<<" "<<v[i]<<" ";
	}
	else{
		for(int i=n/2;i<v.size();i++)
			cout<<v[i]<<" ";
		for(int i=0;i<n/2;i++)
			cout<<v[i]<<" ";
	}

	cout<<"\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
	ll t;
	cin>>t;
	while(t--){
	ll n;
	cin>>n;
	vector <ll> v(n),v2(n);
	for(int i=0;i<v.size();i++)
		cin>>v[i];

	for(int i=n-1;i>=0;i--)
		cout<<v[i]<<" ";

	cout<<"\n";
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int tc;
    cin>>tc;
    while(tc--){
        int num;
        cin>>num;
        int arr[num];
        for(int i=0; i<num; i++){
            cin>>arr[i];
        }
        if(num%2==0){
            for(int i=0; i<num; i+=2){
                cout<<arr[i+1]<<" "<<arr[i];
            }
            cout<<endl;
        }
        if(num%2!=0){
            int x=num/2;
            for(int i=x; i<num; i++){
                cout<<arr[i]<<" ";
            }
            for(int i=0; i<x; i++){
                cout<<arr[i]<<" ";
            }
            cout<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int tc;
    cin>>tc;
    while(tc--){
        int num;
        cin>>num;
        int arr[num];
        for(int i=0; i<num; i++){
            cin>>arr[i];
        }
        if(num%2==0){
            for(int i=0; i<num; i+=2){
                cout<<arr[i+1]<<" "<<arr[i]<<" ";
            }
            cout<<endl;
        }
        if(num%2!=0){
            int x=num/2;
            for(int i=x; i<num; i++){
                cout<<arr[i]<<" ";
            }
            for(int i=0; i<x; i++){
                cout<<arr[i]<<" ";
            }
            cout<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int tc;
    cin>>tc;
    while(tc--){
        int num;
        cin>>num;
        vector<int>arr(num);
        for(int i=0; i<num; i++){
            cin>>arr[i];
        }
        reverse(arr.begin(),arr.end());
        for(auto it:arr){
            cout<<it<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int tc;
    cin>>tc;
    while(tc--){
        int num;
        cin>>num;
        int arr[num];
        for(int i=0; i<num; i++){
            cin>>arr[i];
        }
        if(num%2==0){
            for(int i=0; i<num; i+=2){
                cout<<arr[i+1]<<" "<<arr[i];
            }
            cout<<endl;
        }
        if(num%2!=0){
            int x=num/2;
            for(int i=x; i<num; i++){
                cout<<arr[i]<<" ";
            }
            for(int i=0; i<x; i++){
                cout<<arr[i]<<" "
            }
            cout<<endl;
        }
    }
    return 0;
}


//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--)
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    NIMISH
    UPADHYAY{
        ll n,x,j,l;
        cin>>n;
        cin>>x;
        l=x;
        if(l==1)
        l=2;
        ll c[n-1],i;
        for(i=0;i<n-1;i++){
            cin>>j;
            c[i]=x+j;
            x=j;
        }
        cout<<l<<" ";
        for(i=0;i<n-1;i++){
            cout<<c[i]-l<<" ";
            l=c[i]-l;
        }
        cout<<"\n";
    }
}


//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--)
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    NIMISH
    UPADHYAY{
        ll n,x,i;
        cin>>n;
        ll c[n];
        for(i=0;i<n;i++)cin>>c[i];
        for(i=n-1;i>=0;i--)cout<<c[i]<<" ";
        cout<<'\n';
    }
}


//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--)
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    NIMISH
    UPADHYAY{
        ll n,x,j,l;
        cin>>n;
        cin>>x;
        l=1;
        if(x==1)
        l=2;
        ll c[n-1],i;
        for(i=0;i<n-1;i++){
            cin>>j;
            c[i]=x+j;
            x=j;
        }
        cout<<l<<" ";
        for(i=0;i<n-1;i++){
            cout<<c[i]-l<<" ";
            l=c[i]-l;
        }
        cout<<"\n";
    }
}


//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--)
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    NIMISH
    UPADHYAY{
        ll n,x,j,l;
        cin>>n;
        ll c[n];
        for(i=0;i<n;i++)cin>>c[i];
        for(i=n-1;i>=0;i--)cout<<c[i]<<" ";
        cout<<'\n';
    }
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int p[n];
        for(int i=0; i<n; i++) cin >> p[i];
        if(n%2==0){
            for(int i=0; i<n; i+=2){
                swap(p[i],p[i+1]);
            }
            for(int i=0; i<n; i++){
                cout<<p[i]<<' ';
            }
            cout<<'\n';
        }else{
            vector<int> a;
            vector<int> b;
            for(int i=(n/2); i<n; i++){
                cout<<p[i]<<' ';
            }
            for(int i=0; i<n/2; i++){
                cout<<p[i]<<' ';
            }
            cout<<'\n';
        }
    }

    return 0;
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int p[n];
        for(int i=0; i<n; i++){
            cin >> p[i];
        }
        reverse(p,p+n);
        for(int i=0; i<n; i++){
            cout<<p[i]<<' ';
        }
        cout<<'\n';
    }

    return 0;
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int p[n];
        for(int i=0; i<n; i++) cin >> p[i];
        if(n%2==0){
            for(int i=0; i<n; i+=2){
                swap(p[i],p[i+1]);
            }
            for(int i=0; i<n; i++){
                cout<<p[i]<<' ';
            }
            cout<<'\n';
        }else{
            for(int i=0; i<n/2; i+=2){
                swap(p[i],p[i+1]);
            }
            for(int i=n/2+1; i<n; i+=2){
                swap(p[i],p[i+1]);
            }
            for(int i=0; i<n; i++){
                cout<<p[i]<<' ';
            }
            cout<<'\n';
        }
    }

    return 0;
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int p[n];
        for(int i=0; i<n; i++) cin >> p[i];
        if(n%2==0){
            for(int i=0; i<n; i+=2){
                swap(p[i],p[i+1]);
            }
            for(int i=0; i<n; i++){
                cout<<p[i]<<' ';
            }
            cout<<'\n';
        }else{
            int i=0;
            for(i; i<n-3; i+=2){
                swap(p[i],p[i+1]);
            }
            swap(p[i],p[i+2]);
            for(int i=0; i<n; i++){
                cout<<p[i]<<' ';
            }
            cout<<'\n';
        }
    }

    return 0;
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int p[n];
        for(int i=0; i<n; i++) cin >> p[i];
        if(n%2==0){
            for(int i=0; i<n; i+=2){
                swap(p[i],p[i+1]);
            }
        }else{
            int i=0;
            for(; i<n-3; i+=2){
                swap(p[i],p[i+1]);
            }
            swap(p[i+1],p[i+2]);
            swap(p[i+2],p[i]);
        }

        for(int i=0; i<n; i++){
            cout<<p[i]<<' ';
        }
        cout<<'\n';
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define faster ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define lli long long int
#define ll long long
#define fox(n) for (ll i = 0; i < n; ++i)
#define fox1(n) for (ll i = 1; i <= n; ++i)
#define foa(v) for (auto el:v)
#define pub push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define opp(v) v.begin(), v.end(), greater<>()
#define endl "\n"

void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    fox(n) cin >> v[i];
//    reverse(v.begin(), v.end());
    fox(n) {
        ll temp = v[i];
        v[i] = v[n-1-i];
        v[n-1-i] = temp;

    }
    fox(n) cout << v[i] << " ";
    cout << endl;
}

int main() {
    faster;
    int tests;
    cin >> tests;
    for (; tests; --tests)
        solve();
}

// 2 4 3 1 5
//  6 7 4 6
// 1 5 2 2 4
// 2 4 3 1 5


#include <bits/stdc++.h>

using namespace std;

#define faster ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define lli long long int
#define ll long long
#define fox(n) for (ll i = 0; i < n; ++i)
#define fox1(n) for (ll i = 1; i <= n; ++i)
#define foa(v) for (auto el:v)
#define pub push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define opp(v) v.begin(), v.end(), greater<>()
#define endl "\n"

void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n), u(n);
    fox(n) cin >> v[i];
    for (int i = 0; i < n-1; i += 2) {
        ll temp = v[i];
        v[i] = v[i + 1];
        v[i + 1] = temp;
    }
    fox(n) cout << v[i] << " ";
    cout << endl;
}

int main() {
    faster;
    int tests;
    cin >> tests;
    for (; tests; --tests)
        solve();
}


#include <bits/stdc++.h>

using namespace std;

#define faster ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define lli long long int
#define ll long long
#define fox(n) for (ll i = 0; i < n; ++i)
#define fox1(n) for (ll i = 1; i <= n; ++i)
#define foa(v) for (auto el:v)
#define pub push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define opp(v) v.begin(), v.end(), greater<>()
#define endl "\n"

void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    fox(n) cin >> v[i];
    reverse(v.begin(), v.end());
    fox(n) cout << v[i] << " ";
    cout << endl;
}

int main() {
    faster;
    int tests;
    cin >> tests;
    for (; tests; --tests)
        solve();
}

// 2 4 3 1 5
//  6 7 4 6
// 1 5 2 2 4
// 2 4 3 1 5


#include <bits/stdc++.h>

using namespace std;

#define faster ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define lli long long int
#define ll long long
#define fox(n) for (ll i = 0; i < n; ++i)
#define fox1(n) for (ll i = 1; i <= n; ++i)
#define foa(v) for (auto el:v)
#define pub push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define opp(v) v.begin(), v.end(), greater<>()
#define endl "\n"

void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    fox(n) cin >> v[i];
//    reverse(v.begin(), v.end());
    fox(n/2) {
        ll temp = v[i];
        v[i] = v[n-1-i];
        v[n-1-i] = temp;

    }
    fox(n) cout << v[i] << " ";
    cout << endl;
}

int main() {
    faster;
    int tests;
    cin >> tests;
    for (; tests; --tests)
        solve();
}

// 2 4 3 1 5
//  6 7 4 6
// 1 5 2 2 4
// 2 4 3 1 5


#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<string>
#define ll long long int
#define loop(a,b,i) for(int i=a;i<b;i++)
#define loopr(a,b,i) for(int i=n-1;i>=0;i--)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define N 10000000
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, MOD - 2);}
using namespace std;

ll digsum(ll n)
{
    ll ans=0;
    while(n!=0)
    {
        ans=ans+(n%10);
        n/=10;
    }
    return ans;
}

int main()
{ quick;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    // ll t;
    // cin>>t;
    // while(t--)
    // {
        ll n;
        cin>>n;
        while(digsum(n)%4!=0)
        {
            n++;
        }
        cout<<n<<endl;
    // }

    return 0;
}


#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<string>
#define ll long long int
#define loop(a,b,i) for(int i=a;i<b;i++)
#define loopr(a,b,i) for(int i=n-1;i>=0;i--)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define N 10000000
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, MOD - 2);}
using namespace std;

ll digsum(ll n)
{
    ll ans=0;
    while(n!=0)
    {
        ans=ans+(n%10);
        n/=10;
    }
    return ans;
}

int main()
{ quick;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        loop(0,n,i){
            cin>>a[i];
        }
        if(n%2==0){
            for(ll i=n-1;i>=0;i--){
                cout<<a[i]<<" ";
            }cout<<endl;
        }
        else
        {
            for(ll i=(n/2)+1;i<n;i++)
                cout<<a[i]<<" ";
            for(ll i=0;i<=n/2;i++)
                cout<<a[i]<<" ";
            cout<<endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<string>
#define ll long long int
#define loop(a,b,i) for(int i=a;i<b;i++)
#define loopr(a,b,i) for(int i=n-1;i>=0;i--)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define N 10000000
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, MOD - 2);}
using namespace std;

ll digsum(ll n)
{
    ll ans=0;
    while(n!=0)
    {
        ans=ans+(n%10);
        n/=10;
    }
    return ans;
}

int main()
{ quick;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        loop(0,n,i){
            cin>>a[i];
        }
        // if(n%2==1)
        // {
            for(ll i=n-1;i>=0;i--)
            {
                cout<<a[i]<<" ";
            }
            cout<<endl;
        // }
        // else
        // {
        //     for(ll i=(n/2);i<n;i++){
        //         cout<<a[i]<<" ";
        //     }
        //     for(ll i=0;i<n/2;i++){
        //         cout<<a[i]<<" ";
        //     }
        //     cout<<endl;
        // }
    }

    return 0;
}


#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<string>
#define ll long long int
#define loop(a,b,i) for(int i=a;i<b;i++)
#define loopr(a,b,i) for(int i=n-1;i>=0;i--)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define N 10000000
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, MOD - 2);}
using namespace std;

ll digsum(ll n)
{
    ll ans=0;
    while(n!=0)
    {
        ans=ans+(n%10);
        n/=10;
    }
    return ans;
}

int main()
{ quick;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        loop(0,n,i){
            cin>>a[i];
        }
        if(n%2==0)
        {
            for(ll i=n-1;i>=0;i--)
            {
                cout<<a[i]<<" ";
            }
            cout<<endl;
        }
        else
        {
            for(ll i=(n/2);i<n;i++){
                cout<<a[i]<<" ";
            }
            for(ll i=0;i<n/2;i++){
                cout<<a[i]<<" ";
            }
            cout<<endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define N 200005
using namespace std;
int main()
{
    int test;
    cin>>test;
    while(test--){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++) cin>>a[i];
        swap(a[0],a[1]);
        for(int i=0;i<n;i++) cout<<a[i]<<" ";
        cout<<"\n";
    }
    return 0;
}

/*
- Check for edge cases
- Check for RTE - Out of bound access, Divide by 0
- int or ll ?
- clear vector/set/map in each test case
*/


#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define N 200005
using namespace std;
int main()
{
    int test;
    cin>>test;
    while(test--){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++) cin>>a[i];
        cout<<a[1]<<" "<<a[0]<<" ";
        for(int i=2;i<n;i++) cout<<a[i]<<" ";
        cout<<"\n";
    }
    return 0;
}

/*
- Check for edge cases
- Check for RTE - Out of bound access, Divide by 0
- int or ll ?
- clear vector/set/map in each test case
*/


#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define N 105
using namespace std;
int a[N],sum[N];
int main()
{
    int test;
    cin>>test;
    while(test--){
        int n;
        cin>>n;
        for(int i=0;i<n;i++) cin>>a[i];
        for(int i=n-1;i>=0;i--) cout<<a[i]<<" ";
        cout<<"\n";
    }
    return 0;
}

/*
- Check for edge cases
- Check for RTE - Out of bound access, Divide by 0
- int or ll ?
- clear vector/set/map in each test case
*/


#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define N 200005
using namespace std;
int main()
{
    int test;
    cin>>test;
    while(test--){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++) cin>>a[i];
        int c=a[1];
        a[1]=a[0];
        a[0]=c;
        for(int i=0;i<n;i++) cout<<a[i]<<" ";
        cout<<"\n";
    }
    return 0;
}

/*
- Check for edge cases
- Check for RTE - Out of bound access, Divide by 0
- int or ll ?
- clear vector/set/map in each test case
*/


#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define N 200005
using namespace std;
int main()
{
    int test;
    cin>>test;
    while(test--){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++) cin>>a[i];
        int i=0,j=n-1;
        while(i<=j){
            if(i==j) cout<<a[i]<<" ";
            else cout<<a[i]<<" "<<a[j]<<" ";
            i++,j--;
        }
        cout<<"\n";
    }
    return 0;
}

/*
- Check for edge cases
- Check for RTE - Out of bound access, Divide by 0
- int or ll ?
- clear vector/set/map in each test case
*/


#include<bits/stdc++.h>
using namespace std;
void kick()
{
    int n;
    cin>>n;
    int ar[n];
    for(int i=0; i<n; i++)cin>>ar[i];
//
//    if(n%2==0){
//        for(int i=n/2; i<n;i++)cout<<ar[i]<<" ";
//        for(int i=0; i<n/2; i++)cout<<ar[i]<<" ";
//    }
//    else{
//        for(int i)
//    }
    cout<<ar[n-1]<<" ";
    for(int i=0; i<n-1; i++)cout<<ar[i]<<" ";
    cout<<"\n";
}
int main()
{
    int t;
    cin>>t;
    while(t--)kick();
}


#include<bits/stdc++.h>
using namespace std;
void kick()
{
    int n;
    cin>>n;
    int ar[n];
    for(int i=0; i<n; i++)cin>>ar[i];
    for(int i=0; i<n; i++)cout<<ar[i]<<" ";
    cout<<"\n";
}
int main()
{
    int t;
    cin>>t;
    while(t--)kick();
}


import java.util.Scanner;
public class Cdf{
    public static void main(String[] err){
        Scanner scn=new Scanner(System.in);
        int p=1;
        int z=0;
        int x=0;
        int i;
        int n=scn.nextInt();
        int[] arr=new int[n];
        for(i=0;i<n;i++)
        arr[i]=scn.nextInt();
        for(i=0;i<n;i++){
            if(arr[i]>1){
            x+=arr[i]-1;
            arr[i]=1;
        }
        else if(arr[i]<-1){
            x+= (-1)*arr[i]-1;
            arr[i]=-1;
        }
        else if(arr[i]==0)
        z++;
        p*=arr[i];
        }
        if(p==1)
        System.out.println(x);
        else if(p==-1)
        System.out.println(x+2);
        else
        System.out.println(x+z);
    }
}


import java.io.BufferedInputStream;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        // int t = scan.nextInt();
        // while(t-->0) {
        int n = scan.nextInt();
        int[] arr = new int[n];
        int cost = 0;
        int oddCount = 0 , zeroCount = 0;
        for(int i = 0 ; i < arr.length ; i++) {
            arr[i] = scan.nextInt();
            if(arr[i]>0){
                cost += arr[i]-1;
            } else if(arr[i] < 0) {
                cost += Math.abs(arr[i])-1;
                oddCount++;
            } else {
                zeroCount++;
            }
        }
        if(zeroCount == 0 && oddCount%2==0) {
            System.out.println(cost);
            return;
        }
        if(zeroCount == 0 && (oddCount % 2 != 0)){
            int minCost = Integer.MAX_VALUE;
            for(int i = 0 ; i < arr.length ; i++) {
                if(minCost == 1) break;
                if(arr[i]>0) {
                    if (arr[i] == 1) continue;
                    minCost = Math.min(arr[i]-1,minCost);
                } else if(arr[i] < 0) {
                    minCost = Math.min(Math.abs(arr[i]-1),minCost);
                } else {
                	cost++;
                }
            }
            cost += minCost;
            System.out.println(cost);
            return;
        }
        if(zeroCount != 0 && oddCount%2==0) {
            cost += zeroCount;
            System.out.println(cost);
            return;
        }
        if(zeroCount != 0 && (oddCount % 2 != 0)) {
            cost += zeroCount;
            System.out.println(cost);
            return;
        }
        System.out.println(cost);
        // }
    }
}


import java.io.BufferedInputStream;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        // int t = scan.nextInt();
        // while(t-->0) {
        int n = scan.nextInt();
        int[] arr = new int[n];
        int cost = 0;
        int oddCount = 0 , zeroCount = 0;
        for(int i = 0 ; i < arr.length ; i++) {
            arr[i] = scan.nextInt();
            if(arr[i]>0){
                cost += arr[i]-1;
            } else if(arr[i] < 0) {
                cost += Math.abs(arr[i])-1;
                oddCount++;
            } else {
                zeroCount++;
            }
        }
        if(zeroCount == 0 && oddCount%2==0) {
            System.out.println(cost);
            return;
        }
        if(zeroCount == 0 && (oddCount % 2 != 0)){
            int minCost = Integer.MAX_VALUE;
            for(int i = 0 ; i < arr.length ; i++) {
                if(minCost == 1) break;
                if(arr[i]>0) {
                    if (arr[i] == 1) continue;
                    minCost = Math.min(arr[i]-1,minCost);
                } else if(arr[i] < 0) {
                    minCost = Math.min(Math.abs(arr[i]-1),minCost);
                }
            }
            cost += minCost;
            System.out.println(cost);
            return;
        }
        if(zeroCount != 0 && oddCount%2==0) {
            cost += zeroCount;
            System.out.println(cost);
            return;
        }
        if(zeroCount != 0 && (oddCount % 2 != 0)) {
            cost += zeroCount;
            System.out.println(cost);
            return;
        }
        System.out.println(cost);
        // }
    }
}


import java.io.BufferedInputStream;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        // int t = scan.nextInt();
        // while(t-->0) {
        int n = scan.nextInt();
        int[] arr = new int[n];
        int cost = 0;
        int oddCount = 0 , zeroCount = 0;
        for(int i = 0 ; i < arr.length ; i++) {
            arr[i] = scan.nextInt();
            if(arr[i]>0){
                cost += arr[i]-1;
            } else if(arr[i] < 0) {
                cost += Math.abs(arr[i])-1;
                oddCount++;
            } else {
                zeroCount++;
            }
        }
        if(zeroCount == 0 && oddCount%2==0) {
            System.out.println(cost);
            return;
        }
        if(zeroCount == 0 && (oddCount % 2 != 0)){
            cost += 2;
            System.out.println(cost);
            return;
        }
        if(zeroCount != 0 && oddCount%2==0) {
            cost += zeroCount;
            System.out.println(cost);
            return;
        }
        if(zeroCount != 0 && (oddCount % 2 != 0)) {
            cost += zeroCount;
            System.out.println(cost);
            return;
        }
        System.out.println(cost);
        // }
    }
}


import java.io.BufferedInputStream;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        // int t = scan.nextInt();
        // while(t-->0) {
        int n = scan.nextInt();
        int[] arr = new int[n];
        long cost = 0;
        int oddCount = 0 , zeroCount = 0;
        for(int i = 0 ; i < arr.length ; i++) {
            arr[i] = scan.nextInt();
            if(arr[i]>0){
                cost += arr[i]-1;
            } else if(arr[i] < 0) {
                cost += Math.abs(arr[i])-1;
                oddCount++;
            } else {
                zeroCount++;
            }
        }
        if(zeroCount == 0 && oddCount%2==0) {
            System.out.println(cost);
            return;
        }
        if(zeroCount == 0 && (oddCount % 2 != 0)){
            cost += 2;
            System.out.println(cost);
            return;
        }
        if(zeroCount != 0 && oddCount%2==0) {
            cost += zeroCount;
            System.out.println(cost);
            return;
        }
        if(zeroCount != 0 && (oddCount % 2 != 0)) {
            cost += zeroCount;
            System.out.println(cost);
            return;
        }
        System.out.println(cost);
        // }
    }
}


//https://codeforces.com/problemset/problem/1206/B

import java.util.Scanner;
public class CF1206B{
public static void main(String args[]){

Scanner sc=new Scanner(System.in);

long negativeCount=0;
long zero=0;
long positiveCount=0;

long negativeNumber=0;
long zeroNumber=0;
long positiveNumber=0;

int a=sc.nextInt();
int arr[]=new int[a];
for(int i=0;i<a;i++){
arr[i]=sc.nextInt();
if(arr[i]>0) {positiveCount+=arr[i]-1;
positiveNumber++;
}
else if (arr[i]<0) {
negativeCount+=(-(arr[i]+1));
negativeNumber++;
}else {zero++;
}
}

long result=0;
if(negativeNumber%2==0){result=positiveCount+negativeCount+zero;
}
else if(negativeNumber%2!=0 && zero==0)
result=positiveCount+negativeCount+zero+2;
else
result=positiveCount+negativeCount+zero;

System.out.print(result);

}}


//https://codeforces.com/problemset/problem/1206/B

import java.util.Scanner;
public class CF1206B{
public static void main(String args[]){

Scanner sc=new Scanner(System.in);

int negativeCount=0;
int zero=0;
int positiveCount=0;

int negativeNumber=0;
int zeroNumber=0;
int positiveNumber=0;

int a=sc.nextInt();
int arr[]=new int[a];
for(int i=0;i<a;i++){
arr[i]=sc.nextInt();
if(arr[i]>0) {positiveCount+=arr[i]-1;
negativeNumber++;
}
else if (arr[i]<0) {
negativeCount+=(-(arr[i]+1));
negativeNumber++
}else {zero++;
}
}

int result=0;
if(negativeNumber%2==0){result=positiveCount+negativeCount+zero;
}
else if(negativeNumber%2!=0 && zero==0)
result=positiveCount+negativeCount+zero+2;
else
result=positiveCount+negativeCount+zero+1;

System.out.print(result);

}}


//https://codeforces.com/problemset/problem/1206/B

import java.util.Scanner;
public class CF1206B{
public static void main(String args[]){

Scanner sc=new Scanner(System.in);

int negativeCount=0;
int zero=0;
int positiveCount=0;

int negativeNumber=0;
int zeroNumber=0;
int positiveNumber=0;

int a=sc.nextInt();
int arr[]=new int[a];
for(int i=0;i<a;i++){
arr[i]=sc.nextInt();
if(arr[i]>0) {positiveCount+=arr[i]-1;
positiveNumber++;
}
else if (arr[i]<0) {
negativeCount+=(-(arr[i]+1));
negativeNumber++;
}else {zero++;
}
}

int result=0;
if(negativeNumber%2==0){result=positiveCount+negativeCount+zero;
}
else if(negativeNumber%2!=0 && zero==0)
result=positiveCount+negativeCount+zero+2;
else
result=positiveCount+negativeCount+zero;

System.out.print(result);

}}


//https://codeforces.com/problemset/problem/1206/B

import java.util.Scanner;
public class CF1206B{
public static void main(String args[]){

Scanner sc=new Scanner(System.in);

int negativeCount=0;
int zero=0;
int positiveCount=0;

int negativeNumber=0;
int zeroNumber=0;
int positiveNumber=0;

int a=sc.nextInt();
int arr[]=new int[a];
for(int i=0;i<a;i++){
arr[i]=sc.nextInt();
if(arr[i]>0) {positiveCount+=arr[i]-1;
positiveNumber++;
}
else if (arr[i]<0) {
negativeCount+=(-(arr[i]+1));
negativeNumber++;
}else {zero++;
}
}

int result=0;
if(negativeNumber%2==0){result=positiveCount+negativeCount+zero;
}
else if(negativeNumber%2!=0 && zero==0)
result=positiveCount+negativeCount+zero+2;
else
result=positiveCount+negativeCount+zero+1;

System.out.print(result);

}}


import java.io.*;
import java.util.*;
public class MakeProductEqualOne {
	public static void main (String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(f.readLine());
		StringTokenizer st = new StringTokenizer(f.readLine());
		int ans = 0;
		int negatives = 0;
		for (int i = 0; i<n; i++) {
			int a = Integer.parseInt(st.nextToken());
			ans += Math.abs(Math.abs(a)-1);
			if (a < 0) negatives++;
		}
		if (negatives % 2 == 1) ans += 2;
		System.out.println(ans);
	}
}


import java.io.*;
import java.util.*;
public class MakeProductEqualOne {
	public static void main (String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(f.readLine());
		StringTokenizer st = new StringTokenizer(f.readLine());
		long ans = 0;
		long negatives = 0;
		long zeroes = 0;
		for (int i = 0; i<n; i++) {
			long a = Long.parseLong(st.nextToken());
			ans += Math.abs(Math.abs(a)-1);
			if (a < 0) negatives++;
			if (a == 0) zeroes++;
		}
		if (negatives % 2 == 1 && zeroes == 0) ans += 2;
		System.out.println(ans);
	}
}


import java.io.*;
import java.util.*;
public class MakeProductEqualOne {
	public static void main (String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(f.readLine());
		StringTokenizer st = new StringTokenizer(f.readLine());
		int ans = 0;
		int negatives = 0;
		int zeroes = 0;
		for (int i = 0; i<n; i++) {
			int a = Integer.parseInt(st.nextToken());
			ans += Math.abs(Math.abs(a)-1);
			if (a < 0) negatives++;
			if (a == 0) zeroes++;
		}
		if (negatives % 2 == 1 && zeroes == 0) ans += 2;
		System.out.println(ans);
	}
}


import java.io.*;
import java.util.*;
public class MakeProductEqualOne {
	public static void main (String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(f.readLine());
		StringTokenizer st = new StringTokenizer(f.readLine());
		int ans = 0;
		int negatives = 0;
		for (int i = 0; i<n; i++) {
			int a = Integer.parseInt(st.nextToken());
			ans += Math.abs(a)-1;
			if (a < 0) negatives++;
		}
		if (negatives % 2 == 1) ans += 2;
		System.out.println(ans);
	}
}


import java.util.*;
public class product
{
    void calculate(int a[])
    {
        int c=0,n=a.length,s=1;
        for(int i=0;i<n;i++)
        {
            if((a[i]==1)||(a[i]==-1))
                continue;
            if(a[i]==0)
                a[i]=2;
            else
            {
                c+=(int)Math.abs(a[i])-1;
                a[i]=a[i]/(int)Math.abs(a[i]);
            }
        }
        for(int i=0;i<n;i++)
            s=s*a[i];
        if(s==-1)
            c=c+2;
        if(s%2==0)
        {
            for(int i=1;;i++)
            {
                if(s==(int)Math.pow(2,i))
                {
                    c=c+i;
                    break;
                }
            }
        }
        System.out.println(c);
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
        new product().calculate(a);
    }
}


import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class product
{
    void calculate(int a[])
    {
        int c=0,c1=0,n=a.length,s=1;
        for(int i=0;i<n;i++)
        {
            if((a[i]==1)||(a[i]==-1))
                continue;
            else if(a[i]==0)
            {   a[i]=1;
                c1++;
            }
            else
            {
                c+=(int)Math.abs(a[i])-1;
                a[i]=a[i]/(int)Math.abs(a[i]);
            }
        }
        for(int i=0;i<n;i++)
            s=s*a[i];
        if(c1!=0)
         c=c+c1;
        if(s==-1)
            c=c+2;
        System.out.println(c);
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
        new product().calculate(a);
    }
}


import java.util.*;
public class product
{
    void calculate(int a[])
    {
        int c=0,c1=0,n=a.length,s=1;
        for(int i=0;i<n;i++)
        {
            if((a[i]==1)||(a[i]==-1))
                continue;
            else if(a[i]==0)
            {   a[i]=1;
                c1++;
            }
            else
            {
                c+=(int)Math.abs(a[i])-1;
                a[i]=a[i]/(int)Math.abs(a[i]);
            }
        }
        for(int i=0;i<n;i++)
            s=s*a[i];
        if(c1!=0)
         c=c+c1;
        else if(s==-1)
            c=c+2;
        System.out.println(c);
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
        new product().calculate(a);
    }
}


import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class product
{
    void calculate(int a[])
    {
        int c=0,n=a.length,s=1;
        for(int i=0;i<n;i++)
        {
            if((a[i]==1)||(a[i]==-1))
                continue;
            if(a[i]==0)
            {   a[i]=1;
                c++;
            }
            else
            {
                c+=(int)Math.abs(a[i])-1;
                a[i]=a[i]/(int)Math.abs(a[i]);
            }
        }
        for(int i=0;i<n;i++)
            s=s*a[i];
        if(s==-1)
            c=c+2;
        System.out.println(c);
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
        new product().calculate(a);
    }
}


import java.util.*;
public class product
{
    void calculate(int a[])
    {
        int c=0,c1=0,n=a.length,s=1;
        for(int i=0;i<n;i++)
        {
            if((a[i]==1)||(a[i]==-1))
                continue;
            else if(a[i]==0)
            {   a[i]=1;
                c1++;
            }
            else
            {
                c+=(int)Math.abs(a[i])-1;
                a[i]=a[i]/(int)Math.abs(a[i]);
            }
        }
        for(int i=0;i<n;i++)
            s=s*a[i];
        if(s==-1)
            c=c+2;
        System.out.println(c+c1);
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
        new product().calculate(a);
    }
}


import java.util.*;
public class product
{
    void calculate(int a[])
    {
        long c=0;int c1=0,n=a.length,s=1;
        for(int i=0;i<n;i++)
        {
            if((a[i]==1)||(a[i]==-1))
                continue;
            else if(a[i]==0)
            {   a[i]=1;
                c1++;
            }
            else
            {
                c+=(int)Math.abs(a[i])-1;
                a[i]=a[i]/(int)Math.abs(a[i]);
            }
        }
        for(int i=0;i<n;i++)
            s=s*a[i];
        if(c1!=0)
         c=c+c1;
        else if(s==-1)
            c=c+2;
        System.out.println(c);
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
        new product().calculate(a);
    }
}


import java.io.*;
import java.lang.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1 =sc.nextInt();
		long a[]=new long[n1];
		long n=0,z=0;
		long c=0;
		for(int i=0;i<n1;i++){
		    a[i]=sc.nextInt();
		     if(a[i]<0){
		       n++;
		         c+=(-1-a[i]);
		     }else if(a[i]>0)
		           c+=(a[i]-1);
		           else{ c+=1;
		               z++;
		           }

		}
		if((n%2!=0)&&(z==0)){

	    c+=2;}
	    System.out.println(c);

	}
}


import java.io.*;
import java.lang.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1 =sc.nextInt();
		long a[]=new long[n1];
		long n=0,z=0;
		long c=0;
		for(int i=0;i<n1;i++){
		    a[i]=sc.nextInt();
		     if(a[i]<0){
		       n++;
		         c+=(-1-a[i]);
		     }else if(a[i]>0)
		           c+=(a[i]-1);
		           else{ c+=1;
		               z++;
		           }

		}
		if(n%2!=0){
		if((n>z)&&((n-z)%2!=0))
	    c+=2;}
	    System.out.println(c);

	}
}


import java.io.*;
import java.lang.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1 =sc.nextInt();
		int a[]=new int[n1];
		int n=0;
		int c=0;
		for(int i=0;i<n1;i++){
		    a[i]=sc.nextInt();
		     if(a[i]<0){
		       n++;
		         c+=(-1-a[i]);
		     }else if(a[i]>0)
		           c+=(a[i]-1);
		           else c+=1;

		}

		if(n%2!=0)
	    c+=2;
	    System.out.println(c);

	}
}


import java.io.*;
import java.lang.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1 =sc.nextInt();
		int a[]=new int[n1];
		int n=0,z=0;
		int c=0;
		for(int i=0;i<n1;i++){
		    a[i]=sc.nextInt();
		     if(a[i]<0){
		       n++;
		         c+=(-1-a[i]);
		     }else if(a[i]>0)
		           c+=(a[i]-1);
		           else{ c+=1;
		               z++;
		           }

		}

		if((n>z)&&((n-z)%2!=0))
	    c+=2;
	    System.out.println(c);

	}
}


import java.io.*;
import java.lang.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1 =sc.nextInt();
		int a[]=new int[n1];
		int n=0,z=0;
		int c=0;
		for(int i=0;i<n1;i++){
		    a[i]=sc.nextInt();
		     if(a[i]<0){
		       n++;
		         c+=(-1-a[i]);
		     }else if(a[i]>0)
		           c+=(a[i]-1);
		           else{ c+=1;
		               z++;
		           }

		}
		if(n%2!=0){
		if((n>z)&&((n-z)%2!=0))
	    c+=2;}
	    System.out.println(c);

	}
}


import java.util.HashMap;
import java.util.Scanner;

public class GFG {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int a[]=new int[n];
		int neg=0;
		int pos=0;
		int zero=0;
		for(int i=0;i<n;i++){
			a[i]=s.nextInt();
			if(a[i]<0) neg++;
			else if(a[i]>0) pos++;
			else zero++;
		}
		int ans=0;
		if(neg%2==1&&pos%2==0&&zero%2==0) {
			if(zero==0) {
				int min=Integer.MAX_VALUE;
				for(int i=0;i<n;i++) {
					if(a[i]>0) {
						min=Math.min(min,a[i]);
					}
				}
				int temp=min;
				for(int i=0;i<n;i++) {
					if(a[i]<0) ans+=(-1-a[i]);
					else if(a[i]>0&&a[i]==min){
						ans+=(min+1);
						min=Integer.MAX_VALUE;
					}
					else if(a[i]>0&&a[i]!=min) {
						ans+=(a[i]-1);
					}
				}
				ans+=zero;

			}
			else if(zero==0&&pos==0) {
				int max=Integer.MIN_VALUE;
				for(int i=0;i<n;i++) {
					max=Math.max(max,a[i]);
				}
				int temp=max;
				for(int i=0;i<n;i++) {
					if(a[i]!=max) ans+=(-1-a[i]);
					else if(a[i]==max) {
						ans+=(1+max);
						max=Integer.MIN_VALUE;
					}
				}
			}
			else {
				for(int i=0;i<n;i++) {
					if(a[i]<0) ans+=(-1-a[i]);
					else if(a[i]>0) ans+=(a[i]-1);
				}
				ans+=zero;
			}

		}
		else if(neg%2==1&&pos%2==0&&zero%2==1) {
			for(int i=0;i<n;i++) {
				if(a[i]<0) ans+=(-1-a[i]);
				else if(a[i]>0) ans+=(a[i]-1);
			}
			ans+=zero;
		}
		else if(neg%2==1&&pos%2==1&&zero%2==0) {
			int min=Integer.MAX_VALUE;
			for(int i=0;i<n;i++) {
				if(a[i]>0) {
					min=Math.min(min,a[i]);
				}
			}
			for(int i=0;i<n;i++) {
				if(a[i]<0) ans+=(-1-a[i]);
				else if(a[i]>0&&a[i]==min){
					ans+=(min+1);
					min=Integer.MAX_VALUE;
				}
				else if(a[i]>0&&a[i]!=min) {
					ans+=(a[i]-1);
				}

			}
			ans+=zero;
		}
		else {
			for(int i=0;i<n;i++) {
				if(a[i]<0) ans+=(-1-a[i]);
				else if(a[i]>0) {
					ans+=(a[i]-1);
				}
			}
			 ans+=zero;
		}

		System.out.println(ans);

	}
}


import java.util.HashMap;
import java.util.Scanner;

public class GFG {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int a[]=new int[n];
		int neg=0;
		int pos=0;
		int zero=0;
		for(int i=0;i<n;i++){
			a[i]=s.nextInt();
			if(a[i]<0) neg++;
			else if(a[i]>0) pos++;
			else zero++;
		}
		long ans=0;
		if(neg%2==1&&pos%2==0&&zero%2==0) {
			if(zero==0&&pos!=0) {
				int min=Integer.MAX_VALUE;
				for(int i=0;i<n;i++) {
					if(a[i]>0) {
						min=Math.min(min,a[i]);
					}
				}
				int temp=min;
				for(int i=0;i<n;i++) {
					if(a[i]<0) ans+=(-1-a[i]);
					else if(a[i]>0&&a[i]==min){
						ans+=(min+1);
						min=Integer.MAX_VALUE;
					}
					else if(a[i]>0&&a[i]!=min) {
						ans+=(a[i]-1);
					}
				}
				ans+=zero;

			}
			else if(zero==0&&pos==0) {
				int max=Integer.MIN_VALUE;
				for(int i=0;i<n;i++) {
					max=Math.max(max,a[i]);
				}
				int temp=max;
				for(int i=0;i<n;i++) {
					if(a[i]!=max) ans+=(-1-a[i]);
					else if(a[i]==max) {
						ans+=(1-max);
						max=Integer.MIN_VALUE;
					}
				}
			}
			else {
				for(int i=0;i<n;i++) {
					if(a[i]<0) ans+=(-1-a[i]);
					else if(a[i]>0) ans+=(a[i]-1);
				}
				ans+=zero;
			}

		}
		else if(neg%2==1&&pos%2==0&&zero%2==1) {
			for(int i=0;i<n;i++) {
				if(a[i]<0) ans+=(-1-a[i]);
				else if(a[i]>0) ans+=(a[i]-1);
			}
			ans+=zero;
		}
		else if(neg%2==1&&pos%2==1&&zero%2==0) {
			int min=Integer.MAX_VALUE;
			for(int i=0;i<n;i++) {
				if(a[i]>0) {
					min=Math.min(min,a[i]);
				}
			}
			for(int i=0;i<n;i++) {
				if(a[i]<0) ans+=(-1-a[i]);
				else if(a[i]>0&&a[i]==min){
					ans+=(min+1);
					min=Integer.MAX_VALUE;
				}
				else if(a[i]>0&&a[i]!=min) {
					ans+=(a[i]-1);
				}

			}
			ans+=zero;
		}
		else {
			for(int i=0;i<n;i++) {
				if(a[i]<0) ans+=(-1-a[i]);
				else if(a[i]>0) {
					ans+=(a[i]-1);
				}
			}
			 ans+=zero;
		}

		System.out.println(ans);

	}
}


import java.util.ArrayList;
import java.util.Scanner;

public class GFG {
	public static void main(String[] args) {
	 Scanner s=new Scanner(System.in);
	 int n=s.nextInt();
	 int pos=0;
	 int z=0;
	 ArrayList<Integer> l=new ArrayList<>();
	 for(int i=0;i<n;i++) {
		 int x=s.nextInt();
		 if(x>0) pos+=x-1;
		 else if(x==0) z++;
		 else l.add(x);
	 }
	 if(l.size()==0) System.out.println(pos+z);
	 else if(l.size()%2==0||z>0) {
		int sum=0;
		for(int i=0;i<l.size();i++) {
			sum+=l.get(i);
		}
	    System.out.println(Math.abs(sum+l.size())+pos+z);
	 }
	 else {
		 int sum=0;
			for(int i=0;i<l.size();i++) {
				sum+=l.get(i);
			}
		System.out.println(Math.abs(sum+l.size())+2+pos+z);
	 }
	}
}


import java.util.ArrayList;
import java.util.Scanner;

public class GFG {
	public static void main(String[] args) {
	 Scanner s=new Scanner(System.in);
	 int n=s.nextInt();
	 long pos=0;
	 int z=0;
	 ArrayList<Integer> l=new ArrayList<>();
	 for(int i=0;i<n;i++) {
		 int x=s.nextInt();
		 if(x>0) pos+=x-1;
		 else if(x==0) z++;
		 else l.add(x);
	 }
	 if(l.size()==0){
		 long ans=pos+z;
		 System.out.println(ans);
	 }
	 else if(l.size()%2==0||z>0) {
		long sum=0;
		for(int i=0;i<l.size();i++) {
			sum+=l.get(i);
		}
		sum=Math.abs(sum+l.size())+pos+z;
	    System.out.println(sum);
	 }
	 else {
		 long sum=0;
			for(int i=0;i<l.size();i++) {
				sum+=l.get(i);
			}
			sum=Math.abs(sum+l.size())+2+pos+z;
		System.out.println(sum);
	 }
	}
}


import java.util.ArrayList;
import java.util.Scanner;

public class GFG {
	public static void main(String[] args) {
	 Scanner s=new Scanner(System.in);
	 int n=s.nextInt();
	 int a[]=new int[n];
	 ArrayList<Integer> pos=new ArrayList<>();
	 ArrayList<Integer> neg=new ArrayList<>();
	 for(int i=0;i<n;i++) {
		 a[i]=s.nextInt();
		 if(a[i]>=0) pos.add(a[i]);
		 else neg.add(a[i]);
	 }
	 long ans=0;
	 for(int i=0;i<pos.size();i++)  {
		 ans+=Math.abs(pos.get(i)-1);
	 }
	 for(int i=0;i<neg.size();i++) {
		 ans+=Math.abs(neg.get(i)+1);
	 }
	 System.out.println(ans);
	}
}


import java.util.*;
public class TEST{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);

		char s[]=sc.next().toCharArray();
		char t[]=sc.next().toCharArray();

	}
}


import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String args[]) {
		Scanner sc=new Scanner (System.in);
		int n=sc.nextInt();

		int a[]=new int [n];
		int A=0,B=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			if(a[i]<0) {
				B++;
			}else {
				A++;
			}
		}

		boolean T=false;
		if(B%2!=0) {
			T=true;
		}else {
			T=false;
		}
		Arrays.sort(a);
		//System.out.println(A+" "+B);
		int sum=0;
		for(int i=0;i<n;i++) {
			if(T) {
				sum+=(1-a[B-1]);
				a[B-1]=1;

				if(a[i]>0) {
					sum+=a[i]-1;
				}else if(a[i]==0){
					sum+=1;
				}else {
					sum+=(-1-a[i]);
				}
			}else {
				if(a[i]>0) {
					sum+=a[i]-1;
				}else if(a[i]==0){
					sum+=1;
				}else {
					sum+=(-1-a[i]);
				}

			}
		}
		System.out.println(sum);

	}

}


import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String args[]) {
		Scanner sc=new Scanner (System.in);
		int n=sc.nextInt();

		int a[]=new int [n];
		int A=0,B=0;
		int sum=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			if(a[i]==0) {
				A++;
				sum+=1;
			}else if(a[i]<0){
				B++;
				sum+=(-1-a[i]);
			}else {
				A++;
				sum+=a[i]-1;
			}
		}

		if(B%2!=0) {
			sum+=2;
		}

		System.out.println(sum);

	}

}


import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String args[]) {
		Scanner sc=new Scanner (System.in);
		int n=sc.nextInt();

		int a[]=new int [n];
		int A=0,B=0;
		long sum=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			if(a[i]==0) {
				A++;
			}else if(a[i]<0){
				B++;
				sum+= (-1-a[i]);
			}else {
				sum+= (a[i]-1);
			}
		}

		if(B%2==1) {
			if(A==0) {
				sum+=2;
			}
		}
		sum+=A;

		System.out.println(sum);

	}

}


import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String args[]) {
		Scanner sc=new Scanner (System.in);
		int n=sc.nextInt();

		int a[]=new int [n];
		int A=0,B=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			if(a[i]<=0) {
				B++;
			}else {
				A++;
			}
		}

		boolean T=false;
		if(B%2!=0) {
			T=true;
		}else {
			T=false;
		}
		Arrays.sort(a);
		//System.out.println(A+" "+B);
		int sum=0;
		for(int i=0;i<n;i++) {
			if(T) {
				sum+=(1-a[B-1]);
				a[B-1]=1;

				if(a[i]>0) {
					sum+=a[i]-1;
				}else if(a[i]==0){
					sum+=1;
				}else {
					sum+=(-1-a[i]);
				}
			}else {
				if(a[i]>0) {
					sum+=a[i]-1;
				}else if(a[i]==0){
					sum+=1;
				}else {
					sum+=(-1-a[i]);
				}

			}
		}
		System.out.println(sum);

	}

}


import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String args[]) {
		Scanner sc=new Scanner (System.in);
		int n=sc.nextInt();

		int a[]=new int [n];
		int A=0,B=0;
		int sum=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			if(a[i]==0) {
				A++;
			}else if(a[i]<0){
				B++;
				sum+=(-1-a[i]);
			}else {
				sum+=a[i]-1;
			}
		}

		if(B%2==1) {
			if(A==0) {
				sum+=2;
			}
		}
		sum+=A;

		System.out.println(sum);

	}

}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class JavaApplication30 {

    /**
     * @param args the command line arguments
     */

/**
 *
 * @author DELL
     * @param args the command line arguments
     */

    static Scanner in=new Scanner(System.in);

    public static void main(String[] args) {

        int count=0;

        int a=in.nextInt();int arr[]=new int[a];
        for (int i = 0; i < a; i++) {
            arr[i]=in.nextInt();
        }
        Arrays.sort(arr);
      /**/  int i=0;int counterr=0;
                            while(arr[i]<0){
                                count++;
                                i++;
                                }
                            if(count%2==0){
                                for (int j = 0; j < count; j++) {
                                     if(arr[j]==1){continue;}
                                  counterr=(counterr+Math.abs(arr[j])-1);

                                }
                                for (int j = count; j < arr.length; j++) {
                                    if(arr[j]==1){continue;}
                                    if(arr[j]==0){counterr+=1;continue;}
                                    counterr=(counterr+arr[j]-1);

                                }
                            }

                            else{
                                counterr=counterr+Math.abs(arr[count-1])+1;

                                for (int j = 0; j < count; j++) {
                                    if(arr[j]==1){continue;}
                                    if(j==count-1) continue;

                                  counterr+=Math.abs(arr[j])-2;

                                }
                                for (int j = count; j < arr.length; j++) {
                                     if(arr[j]==1){continue;}
                                    if(j==count-1) continue;
                                    counterr=(counterr-arr[j])+1;

                                }

                            }
                            System.out.println(counterr);
}}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class JavaApplication30 {

    /**
     * @param args the command line arguments
     */

/**
 *
 * @author DELL
     * @param args the command line arguments
     */

    static Scanner in=new Scanner(System.in);

    public static void main(String[] args) {

        int count=0;

        int a=in.nextInt();int arr[]=new int[a];
        for (int i = 0; i < a; i++) {
            arr[i]=in.nextInt();
        }
        Arrays.sort(arr);
      /**/  int i=0;int counterr=0;
                            while(arr[i]<0){
                                count++;
                                i++;
                                }
                            if(count%2==0){
                                for (int j = 0; j < count; j++) {
                                     if(arr[j]==1){continue;}
                                  counterr=(counterr+Math.abs(arr[j])-1);

                                }
                                for (int j = count; j < arr.length; j++) {
                                    if(arr[j]==1){continue;}
                                    if(arr[j]==0){counterr+=1;continue;}
                                    counterr=(counterr+arr[j]-1);

                                }
                            }

                            else{
                                counterr=counterr+Math.abs(arr[count-1])+1;
                                System.out.println(counterr+"   "+count);
                                for (int j = 0; j < count; j++) {
                                    if(arr[j]==1){continue;}
                                    if(j==count-1) continue;

                                  counterr+=Math.abs(arr[j])-2;
                                   System.out.println(counterr+"   "+count);
                                }
                                for (int j = count; j < arr.length; j++) {
                                     if(arr[j]==1){continue;}
                                    if(j==count-1) continue;
                                    counterr=(counterr-arr[j])+1;
                                     System.out.println(counterr+"   "+count);
                                }

                            }
                            System.out.println(counterr);
}}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class JavaApplication30 {

    /**
     * @param args the command line arguments
     */

/**
 *
 * @author DELL
     * @param args the command line arguments
     */

    static Scanner in=new Scanner(System.in);

    public static void main(String[] args) {

        int count=0;

        int a=in.nextInt();int arr[]=new int[a];
        for (int i = 0; i < a; i++) {
            arr[i]=in.nextInt();
        }
        Arrays.sort(arr);
      /**/  int i=0;int counterr=0;
                            while(arr[i]<0){
                                count++;
                                i++;
                                }
                            if(count%2==0){
                                for (int j = 0; j < count; j++) {
                                     if(arr[j]==1){continue;}
                                  counterr=(counterr+Math.abs(arr[j])-1);

                                }
                                for (int j = count; j < arr.length; j++) {
                                    if(arr[j]==1){continue;}
                                    if(arr[j]==0){counterr+=1;continue;}
                                    counterr=(counterr+arr[j]-1);

                                }
                            }

                            else{
                                counterr=counterr+Math.abs(arr[count-1])+1;
                                System.out.println(counterr+"   "+count);
                                for (int j = 0; j < count; j++) {
                                    if(arr[j]==1){continue;}
                                    if(j==count-1) continue;

                                  counterr+=Math.abs(arr[j])-2;

                                }
                                for (int j = count; j < arr.length; j++) {
                                     if(arr[j]==1){continue;}
                                    if(j==count-1) continue;
                                    counterr=(counterr-arr[j])+1;

                                }

                            }
                            System.out.println(counterr);
}}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class JavaApplication30 {

    /**
     * @param args the command line arguments
     */

/**
 *
 * @author DELL
     * @param args the command line arguments
     */

    static Scanner in=new Scanner(System.in);

    public static void main(String[] args) {

        int num =in.nextInt();
        int arr[]=new int[num];
        for (int i = 0; i < num; i++) {
            arr[i]=in.nextInt();
        }
        int result=0;
        if(num==1){
        if(arr[0]==1){result=1;}
        if(arr[0]>1){result=arr[0]-1;}
        if(arr[0]<0){result=Math.abs(arr[0])+1;}
        }
        /*
        more than one
        */
        else{
        int count=0;
        Arrays.sort(arr);
            for (int i = 0; i < num; i++) {
                if(arr[i]<0){count++;}       }

            if(count%2==0){
                for (int i = 0; i < count; i++) {
                    result+=Math.abs(arr[i])-1;
                }
                for (int i = count; i < num; i++) {
                    if(arr[i]==0){result+=1;}
                    else { result+=arr[i]-1; }
                }
       }

            else {

                if(num>2){result+=arr[count];

                for (int i = 0; i < count; i++) {
                    result+=Math.abs(arr[i])+1;
                }

                for (int i = count+1; i < arr.length; i++) {
                    result+=arr[i]-1;
                }}

                else{

                for (int i = 0; i < count; i++) {
                    result+=Math.abs(arr[i])+1;
                }

                for (int i = count+1; i < arr.length; i++) {
                    result+=arr[i]-1;
                }}

            }
        }
        System.out.println(result);

}}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class JavaApplication30 {

    /**
     * @param args the command line arguments
     */

/**
 *
 * @author DELL
     * @param args the command line arguments
     */

    static Scanner in=new Scanner(System.in);

    public static void main(String[] args) {

        int num =in.nextInt();
        long arr[]=new long[num];
        for (int i = 0; i < num; i++) {
            arr[i]=in.nextLong();
        }
        long result=0;

        /*
        more than one
        */

        long count=0;long count2=0;
        Arrays.sort(arr);
            for (int i = 0; i < num; i++) {
                if(arr[i]<0){count++;}else if(arr[i]==0){count2++;}  }
         for (int i = 0; i < num; i++) {
            result+=Math.abs(arr[i]);
        }
         result+=count2;
         result-=(num-count2);
                if(count%2!=0&&count2<=0){result+=2;}

        System.out.println(result);

}}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class JavaApplication30 {

    /**
     * @param args the command line arguments
     */

/**
 *
 * @author DELL
     * @param args the command line arguments
     */

    static Scanner in=new Scanner(System.in);

    public static void main(String[] args) {

        int num =in.nextInt();
        int arr[]=new int[num];
        for (int i = 0; i < num; i++) {
            arr[i]=in.nextInt();
        }
        int result=0;

        /*
        more than one
        */

        int count=0;int count2=0;
        Arrays.sort(arr);
            for (int i = 0; i < num; i++) {
                if(arr[i]<0){count++;}else if(arr[i]==0){count2++;}  }
         for (int i = 0; i < num; i++) {
            result+=Math.abs(arr[i]);
        }
         result+=count2;
         result-=(num-count2);
                if(count%2!=0&&count2<=0){result+=2;}

        System.out.println(result);

}}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class JavaApplication30 {

    /**
     * @param args the command line arguments
     */

/**
 *
 * @author DELL
     * @param args the command line arguments
     */

    static Scanner in=new Scanner(System.in);

    public static void main(String[] args) {

        int num =in.nextInt();
        int arr[]=new int[num];
        for (int i = 0; i < num; i++) {
            arr[i]=in.nextInt();
        }
        int result=0;

        /*
        more than one
        */

        int count=0;int count2=0;
        Arrays.sort(arr);
            for (int i = 0; i < num; i++) {
                if(arr[i]<0){count++;}else if(arr[i]==0){count2++;}  }
         for (int i = 0; i < num; i++) {
            result+=Math.abs(arr[i]);
        }
         result+=count2;
         result-=(num-count2);
                if(count%2!=0&&count2<0){result+=2;}

        System.out.println(result);

}}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class JavaApplication30 {

    /**
     * @param args the command line arguments
     */

/**
 *
 * @author DELL
     * @param args the command line arguments
     */

    static Scanner in=new Scanner(System.in);

    public static void main(String[] args) {

        int count=0;

        int a=in.nextInt();long arr[]=new long[a];
        for (int i = 0; i < a; i++) {
            arr[i]=in.nextLong();
        }
        Arrays.sort(arr);
      /**/  int i=0;long counterr=0;
      if(a!=1){
                            while(arr[i]<0){
                                count++;
                                i++;
                                }
                            if(count%2==0){
                                for (int j = 0; j < count; j++) {
                                     if(arr[j]==1){continue;}
                                  counterr=(counterr+Math.abs(arr[j])-1);

                                }
                                for (int j = count; j < arr.length; j++) {
                                    if(arr[j]==1){continue;}
                                    if(arr[j]==0){counterr+=1;continue;}
                                    counterr=(counterr+arr[j]-1);

                                }
                            }

                            else{
                                counterr=counterr+Math.abs(arr[count-1])+1;

                                for (int j = 0; j < count; j++) {
                                    if(arr[j]==1){continue;}
                                    if(j==count-1) continue;

                                  counterr+=Math.abs(arr[j])-2;

                                }
                                for (int j = count; j < arr.length; j++) {
                                     if(arr[j]==1){continue;}
                                    if(j==count-1) continue;
                                    counterr=(counterr-arr[j])+1;

                                }

                            }}
      else{
      if(arr[0]>0){counterr=arr[0]-1;}
      else if(arr[0]<0){counterr=Math.abs(arr[0])+1;}
      else{counterr=1;}
      }
                            System.out.println(counterr);
}}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();

		int[] arr=new int[n];

		long count=0;
		int neg=0;

		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();

			if(arr[i]<0)
				neg++;

		}

		for(int i=0;i<n;i++)
		{
			int val=0;

			if(arr[i]<=0&&neg%2==0)
			{
				if(arr[i]<0)
				{
					val=Math.abs(arr[i]);
					val--;
				}
				else
				{
					val=Math.abs(arr[i]);
					val++;
				}
			}
			else if(arr[i]<=0&&neg%2!=0)
			{
				val=Math.abs(arr[i]);
				val++;
				neg++;
			}
			else
			{
				val=arr[i]-1;
			}

			count=count+val;
		}

		System.out.println(count);

	}

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();

		int[] arr=new int[n];

		int count=0;
		int neg=0;

		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();

			if(arr[i]<0)
				neg++;

		}

		for(int i=0;i<n;i++)
		{
			int val=0;

			if(arr[i]<=0&&neg%2==0)
			{
				if(arr[i]<0)
				{
					val=Math.abs(arr[i]);
					val--;
				}
				else
				{
					val=Math.abs(arr[i]);
					val++;
				}
			}
			else if(arr[i]<=0&&neg%2!=0)
			{
				val=Math.abs(arr[i]);
				val++;
				neg++;
			}
			else
			{
				val=arr[i]-1;
			}

			count=count+val;
		}

		System.out.println(count);

	}

}


import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();

		Integer[] arr=new Integer[n];

		long count=0;
		int neg=0;

		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();

			if(arr[i]<0)
				neg++;

		}

		Arrays.sort(arr);

		for(int i=n-1;i>=0;i--)
		{
			int val=0;

			if(arr[i]<0&&neg%2==0)
			{

					val=Math.abs(arr[i]);
					val--;
			}
			else if(arr[i]<0&&neg%2!=0)
			{
				val=Math.abs(arr[i]);
				val++;
				neg++;
			}
			else
			{
				if(arr[i]>0)
				val=arr[i]-1;
				else
					val=1;
			}

			count=count+val;
		}

		System.out.println(count);

	}

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();

		int[] arr=new int[n];

		long count=0;
		int neg=0;

		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();

			if(arr[i]<0)
				neg++;

		}

		for(int i=0;i<n;i++)
		{
			int val=0;

			if(arr[i]<0&&neg%2==0)
			{

					val=Math.abs(arr[i]);
					val--;
			}
			else if(arr[i]<0&&neg%2!=0)
			{
				val=Math.abs(arr[i]);
				val++;
				neg++;
			}
			else
			{
				if(arr[i]>0)
				val=arr[i]-1;
				else
					val=1;
			}

			count=count+val;
		}

		System.out.println(count);

	}

}


import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();

		Integer[] arr=new Integer[n];

		long count=0;
		int zero=0;
		int neg=0;

		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();

			if(arr[i]<0)
				neg++;

			if(arr[i]==0)
				zero++;

		}

		if(neg%2!=0&&zero>0)
		{
			neg++;
		}

		Arrays.sort(arr);

		for(int i=n-1;i>=0;i--)
		{
			int val=0;

			if(arr[i]<0&&neg%2==0)
			{

					val=Math.abs(arr[i]);
					val--;
			}
			else if(arr[i]<0&&neg%2!=0)
			{
				val=Math.abs(arr[i]);
				val++;
				neg++;
			}
			else
			{
				if(arr[i]>0)
				val=arr[i]-1;
				else
					val=1;
			}

			count=count+val;
		}

		System.out.println(count);

	}

}


import java.util.*;
public class B1206
{
    public static void main(String[] args)
    {
        Scanner sc  = new Scanner(System.in);
        int n = sc.nextInt();
        long arr[] = new long [n];
        long i,j,count=0,zeros=0;
        for(i=0;i<n;i++)
        {
          arr[i] = sc.nextInt();
          if(arr[i] < 0)
            count++;
        }
        long coins = 0;
        for(i = 0;i <n ;i++)
        {
            if(arr[i]!=0)
              coins+= (Math.abs(arr[i])-1);
            else
            {
              coins++;
              zeros++;
            }
        }
        if(count % 2 !=0)
        {
            if(zeros==0)
              coins = coins + 2;
        }
        System.out.println(coins);
    }
}


import java.util.*;
public class B1206
{
    public static void main(String[] args)
    {
        Scanner sc  = new Scanner(System.in);
        int n = sc.nextInt();
        long arr[] = new long [n];
        int i,j,count=0,zeros=0;
        for(i=0;i<n;i++)
        {
          arr[i] = sc.nextInt();
          if(arr[i] < 0)
            count++;
        }
        long coins = 0;
        for(i = 0;i <n ;i++)
        {
            if(arr[i]!=0)
              coins+= (Math.abs(arr[i])-1);
            else
            {
              coins++;
              zeros++;
            }
        }
        if(count % 2 !=0)
        {
            if(zeros==0)
              coins = coins + 2;
        }
        System.out.println(coins);
    }
}


import java.util.*;
public class B1206
{
    public static void main(String[] args)
    {
        Scanner sc  = new Scanner(System.in);
        int n = sc.nextInt();
        long arr[] = new long [n];
        long long i,j,count=0,zeros=0;
        for(i=0;i<n;i++)
        {
          arr[i] = sc.nextInt();
          if(arr[i] < 0)
            count++;
        }
        long coins = 0;
        for(i = 0;i <n ;i++)
        {
            if(arr[i]!=0)
              coins+= (Math.abs(arr[i])-1);
            else
            {
              coins++;
              zeros++;
            }
        }
        if(count % 2 !=0)
        {
            if(zeros==0)
              coins = coins + 2;
        }
        System.out.println(coins);
    }
}


import java.util.*;
public class B1206
{
    public static void main(String[] args)
    {
        Scanner sc  = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        int i,j,count=0,zeros=0;
        for(i=0;i<n;i++)
        {
          arr[i] = sc.nextInt();
          if(arr[i] < 0)
            count++;
        }
        int coins = 0;
        for(i = 0;i <n ;i++)
        {
            if(arr[i]!=0)
              coins+= (Math.abs(arr[i])-1);
            else
            {
              coins++;
              zeros++;
            }
        }
        if(count % 2 !=0)
        {
            if(zeros==0)
              coins = coins + 2;
        }
        System.out.println(coins);
    }
}


import java.util.*;
public class B1206
{
    public static void main(String[] args)
    {
        Scanner sc  = new Scanner(System.in);
        int n = sc.nextInt();
        long arr[] = new long [n];
        int i,j,count=0,zeros=0;
        for(i=0;i<n;i++)
        {
          arr[i] = sc.nextInt();
          if(arr[i] < 0)
            count++;
        }
        int coins = 0;
        for(i = 0;i <n ;i++)
        {
            if(arr[i]!=0)
              coins+= (Math.abs(arr[i])-1);
            else
            {
              coins++;
              zeros++;
            }
        }
        if(count % 2 !=0)
        {
            if(zeros==0)
              coins = coins + 2;
        }
        System.out.println(coins);
    }
}