#pragma GCC optimize("O3") #include #include #include #include using namespace std; long gcd(long a,long b){return b?gcd(b,a%b):a;} vector >M[1<<7]; int N; long A[7]; main() { cin>>N; for(int i=0;i>A[i]; M[1<(i&~x);x=x-1&i) { int y=i&~x; for(const pair&X:M[x]) { for(const pair&Y:M[y]) { M[i].push_back(make_pair(X.first*Y.second+Y.first*X.second,X.second*Y.second)); M[i].push_back(make_pair(X.first*Y.second-Y.first*X.second,X.second*Y.second)); M[i].push_back(make_pair(-X.first*Y.second+Y.first*X.second,X.second*Y.second)); M[i].push_back(make_pair(X.first*Y.first,X.second*Y.second)); M[i].push_back(make_pair(X.first*Y.second,X.second*Y.first)); M[i].push_back(make_pair(Y.first*X.second,Y.second*X.first)); } } } for(pair&p:M[i]) { long g=gcd(p.first,p.second); p.first/=g; p.second/=g; } sort(M[i].begin(),M[i].end()); M[i].erase(unique(M[i].begin(),M[i].end()),M[i].end()); } for(int i=1;i+1<1<