import java.io.* ;
import java.util.* ;
import static java.
lang .
Math .
*;
public class Main {
FastScanner in;
static final String FILE
= "powerstower" ;
void solve( ) {
int n = in.nextInt ( ) ;
int [ ] ms = new int [ n] ;
for ( int i = 0 ; i < n; i++ )
ms[ i] = in.nextInt ( ) ;
if ( n == 1 ) {
out.print ( ms[ 0 ] % 3 ) ;
return ;
}
for ( int i = n - 1 ; i >= 1 ; i-- ) {
ms[ i] %= 2 ;
if ( ms[ i] == 0 )
ms[ i] = 0 ;
else
ms[ i] = 1 ;
if ( i + 1 < n && ms[ i + 1 ] == 0 )
ms[ i] = 1 ;
}
int old = ms[ 0 ] ;
ms[ 0 ] %= 3 ;
if ( ms[ 0 ] != 2 )
out.print ( ms[ 0 ] ) ;
else
out.print ( ms[ 1 ] == 0 ? 1 : 2 ) ;
}
public void run( ) {
if ( FILE.equals ( "" ) ) {
in
= new FastScanner
( System .
in ) ; } else {
try {
".in" ) ) ;
".out" ) ) ;
e.printStackTrace ( ) ;
}
}
solve( ) ;
out.close ( ) ;
}
public static void main
( String [ ] args
) { ( new Main( ) ) .run ( ) ;
}
class FastScanner {
}
while ( st == null || ! st.hasMoreTokens ( ) ) {
try {
e.printStackTrace ( ) ;
}
}
return st.nextToken ( ) ;
}
st = null ;
try {
return br.readLine ( ) ;
e.printStackTrace ( ) ;
return null ;
}
}
public int nextInt( ) {
}
public long nextLong( ) {
return Long .
parseLong ( next
( ) ) ; }
public double nextDouble( ) {
return Double .
parseDouble ( next
( ) ) ; }
public float nextFloat( ) {
return Float .
parseFloat ( next
( ) ) ; }
}
}
aW1wb3J0IGphdmEuaW8uKjsKaW1wb3J0IGphdmEudXRpbC4qOwoKaW1wb3J0IHN0YXRpYyBqYXZhLmxhbmcuTWF0aC4qOwoKcHVibGljIGNsYXNzIE1haW4gewogICAgRmFzdFNjYW5uZXIgaW47CiAgICBQcmludFdyaXRlciBvdXQ7CgogICAgc3RhdGljIGZpbmFsIFN0cmluZyBGSUxFID0gInBvd2Vyc3Rvd2VyIjsKCiAgICB2b2lkIHNvbHZlKCkgewogICAgICAgIGludCBuID0gaW4ubmV4dEludCgpOwogICAgICAgIGludFtdIG1zID0gbmV3IGludFtuXTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykKICAgICAgICAgICAgbXNbaV0gPSBpbi5uZXh0SW50KCk7CiAgICAgICAgaWYgKG4gPT0gMSkgewogICAgICAgICAgICBvdXQucHJpbnQobXNbMF0gJSAzKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBmb3IgKGludCBpID0gbiAtIDE7IGkgPj0gMTsgaS0tKSB7CiAgICAgICAgICAgIG1zW2ldICU9IDI7CiAgICAgICAgICAgIGlmIChtc1tpXSA9PSAwKQogICAgICAgICAgICAgICAgbXNbaV0gPSAwOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICBtc1tpXSA9IDE7CiAgICAgICAgICAgIGlmIChpICsgMSA8IG4gJiYgbXNbaSArIDFdID09IDApCiAgICAgICAgICAgICAgICBtc1tpXSA9IDE7CiAgICAgICAgfQogICAgICAgIGludCBvbGQgPSBtc1swXTsKICAgICAgICBtc1swXSAlPSAzOwogICAgICAgIGlmIChtc1swXSAhPSAyKQogICAgICAgICAgICBvdXQucHJpbnQobXNbMF0pOwogICAgICAgIGVsc2UKICAgICAgICAgICAgb3V0LnByaW50KG1zWzFdID09IDAgPyAxIDogMik7CiAgICB9CgogICAgcHVibGljIHZvaWQgcnVuKCkgewogICAgICAgIGlmIChGSUxFLmVxdWFscygiIikpIHsKICAgICAgICAgICAgaW4gPSBuZXcgRmFzdFNjYW5uZXIoU3lzdGVtLmluKTsKICAgICAgICAgICAgb3V0ID0gbmV3IFByaW50V3JpdGVyKFN5c3RlbS5vdXQpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBpbiA9IG5ldyBGYXN0U2Nhbm5lcihuZXcgRmlsZUlucHV0U3RyZWFtKEZJTEUgKwogICAgICAgICAgICAgICAgICAgICAgICAiLmluIikpOwogICAgICAgICAgICAgICAgb3V0ID0gbmV3IFByaW50V3JpdGVyKG5ldyBGaWxlT3V0cHV0U3RyZWFtKEZJTEUgKwogICAgICAgICAgICAgICAgICAgICAgICAiLm91dCIpKTsKICAgICAgICAgICAgfSBjYXRjaCAoRmlsZU5vdEZvdW5kRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgICAgIGUucHJpbnRTdGFja1RyYWNlKCk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgc29sdmUoKTsKICAgICAgICBvdXQuY2xvc2UoKTsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgKG5ldyBNYWluKCkpLnJ1bigpOwogICAgfQoKICAgIGNsYXNzIEZhc3RTY2FubmVyIHsKICAgICAgICBCdWZmZXJlZFJlYWRlciBicjsKICAgICAgICBTdHJpbmdUb2tlbml6ZXIgc3Q7CgogICAgICAgIHB1YmxpYyBGYXN0U2Nhbm5lcihJbnB1dFN0cmVhbSBpcykgewogICAgICAgICAgICBiciA9IG5ldyBCdWZmZXJlZFJlYWRlcihuZXcgSW5wdXRTdHJlYW1SZWFkZXIoaXMpKTsKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBTdHJpbmcgbmV4dCgpIHsKICAgICAgICAgICAgd2hpbGUgKHN0ID09IG51bGwgfHwgIXN0Lmhhc01vcmVUb2tlbnMoKSkgewogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICBzdCA9IG5ldyBTdHJpbmdUb2tlbml6ZXIoYnIucmVhZExpbmUoKSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBlKSB7CiAgICAgICAgICAgICAgICAgICAgZS5wcmludFN0YWNrVHJhY2UoKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gc3QubmV4dFRva2VuKCk7CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgU3RyaW5nIG5leHRMaW5lKCkgewogICAgICAgICAgICBzdCA9IG51bGw7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICByZXR1cm4gYnIucmVhZExpbmUoKTsKICAgICAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZSkgewogICAgICAgICAgICAgICAgZS5wcmludFN0YWNrVHJhY2UoKTsKICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgaW50IG5leHRJbnQoKSB7CiAgICAgICAgICAgIHJldHVybiBJbnRlZ2VyLnBhcnNlSW50KG5leHQoKSk7CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgbG9uZyBuZXh0TG9uZygpIHsKICAgICAgICAgICAgcmV0dXJuIExvbmcucGFyc2VMb25nKG5leHQoKSk7CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgZG91YmxlIG5leHREb3VibGUoKSB7CiAgICAgICAgICAgIHJldHVybiBEb3VibGUucGFyc2VEb3VibGUobmV4dCgpKTsKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBmbG9hdCBuZXh0RmxvYXQoKSB7CiAgICAgICAgICAgIHJldHVybiBGbG9hdC5wYXJzZUZsb2F0KG5leHQoKSk7CiAgICAgICAgfQogICAgfQoKfQ==