bzoj#P2908. 又是nand

又是nand

题目描述

给定 nn 个 0/10/1 值 aia_i,从左到右依次做「与非」运算:x1=a1x_1=a_1,xi=NAND(xi−1,ai)x_i=\mathrm{NAND}(x_{i-1},a_i)。求最终结果。与非运算定义为 NAND(p,q)=¬(p∧q)\mathrm{NAND}(p,q)=\lnot(p\land q)。

输入格式

第一行一个整数 nn(1≤n≤1051\le n\le 10^5)。 第二行 nn 个整数 aia_i(0≤ai≤10\le a_i\le 1)。

输出格式

输出一个整数 00 或 11,表示最终结果。

样例输入

4
1 1 0 1

样例输出

0