#include using namespace std; using ll=long long; int main(){ int N; cin>>N; vector E(N); for(auto&e:E)cin>>e; vector group(N,-1); ll ans=0; auto dfs=[&](auto dfs,int i){ if(i==N){ vector S(3); for(int j=0;j