// O(n 2^n)はさすがに通らない(6sくらい) long s[25]; int board[25]; int cnt1,cnt2; void dfs(int n){ cnt2++; board[n]+=2; if(n%5!=0&&board[n-1]<2&&board[n]%2==board[n-1]%2)dfs(n-1);//左 if(n%5!=4&&board[n+1]<2&&board[n]%2==board[n+1]%2)dfs(n+1);//右 if(n>=5&&board[n-5]<2&&board[n]%2==board[n-5]%2)dfs(n-5);//上 if(n<20&&board[n+5]<2&&board[n]%2==board[n+5]%2)dfs(n+5);//下 } int f(){ cnt2=0; dfs(0); int n=0; while(n<25&&board[n]>=2)n++; if(n==25)return 1; if(cnt2!=cnt1&&cnt2+cnt1!=25)return 0; dfs(n); return cnt2==25; } int main(){ long ans=0; for(int i=0;i<25;i++){ scanf("%ld",&s[i]); ans+=s[i]; } for(int n=0;n<1<<25;n++){ long t=0; cnt1=0; for(int k=0;k<25;k++){ board[k]=(n>>k)&1; t+=board[k]?s[k]:-s[k]; if(board[k])cnt1++; } if(f()){ t=labs(t); if(t