#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class TrySail { public:
int get(vector <int> strength)
{
vector<bool> possible(65536, false);
possible[0] = true;
for(int s: strength) {
vector<bool> p2 = possible;
for(int a=0; a<256; ++a)
for(int b=0; b<256; ++b) if(possible[a*256+b])
p2[(a^s)*256+b] = p2[a*256+(b^s)] = true;
possible.swap(p2);
}
int all = 0;
for(int s: strength) all ^= s;
int best = 0;
for(int a=0; a<256; ++a)
for(int b=0; b<256; ++b) if(possible[a*256+b])
best = max(best, a+b+(all^a^b));
return best;
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
bool ok = (Expected == Received);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, TrySail().get(strength));}
int main(){
CASE(0)
int strength_[] = {2,3,3};
vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_));
int _ = 8;
END
CASE(1)
int strength_[] = {7,3,5,2};
vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_));
int _ = 17;
END
CASE(2)
int strength_[] = {13,13,13,13,13,13,13,13};
vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_));
int _ = 26;
END
CASE(3)
int strength_[] = {114,51,4,191,9,81,0,89,3};
vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_));
int _ = 470;
END
CASE(4)
int strength_[] = {108,66,45,82,163,30,83,244,200,216,241,249,89,128,36,28,250,190,70,95,117,196,19,160,255,129,10,109,189,24,22,25,134,144,110,15,235,205,186,103,116,191,119,183,45,217,156,44,97,197};
vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_));
int _ = 567;
END
/*
CASE(5)
int strength_[] = ;
vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_));
int _ = ;
END
CASE(6)
int strength_[] = ;
vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_));
int _ = ;
END
*/
}
// END CUT HERE