Language: C++

#include<iostream>
#include<cmath>
#include<complex>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back

typedef complex<int> P;

const double eps = 1e-10;

double cross(P a,P b){
  return (double)(a.real()*b.imag()-a.imag()*b.real());
}


double dist(P a){
  return sqrt(a.real()*a.real()+a.imag()*a.imag());
}


double isp(P a,P b,P c){
  return dist(a-c)+dist(b-c)< dist(a-b)+eps;
}

int PolygonArea(P *a,int n){
  int sum = 0;
  rep(i,n){
    sum+=(a[i].real()-a[(i+1)%n].real())*(a[i%n].imag()+a[(i+1)%n].imag());
  }
  
  /*
  cout <<"debug"<<endl;
  cout <<"sum " << sum/2 << endl;
  rep(i,n){
    cout << a[i] << endl;
  }
  cout << endl;
  */     

  if (sum < 0)sum*=-1;
  if (sum%2 != 0)return -1;
  else return sum/2;
}

bool isok(int n,P *in){
  rep(i,n){
    REP(j,i+1,n){
      if (in[i].real()==in[j].real() && in[i].imag()==in[j].imag())return false;
    }
  }


  if (n < 3)return true;

  rep(i,n){
    rep(k,n){
      if (k == i || k == (i+1)%n)continue;
      if (isp(in[i],in[(i+1)%n],in[k])){
	
	return false;
      }
    }
  }


  //is convex
  double me = cross(in[1]-in[0],in[2]-in[0]);
  rep(i,n){
    P cur=in[(i+1)%n]-in[i],next=in[(i+2)%n]-in[i];
    double tmp = cross(cur,next);
    //    if (tmp < -eps)return false;
    if (me*tmp < -eps)return false;
  }
  return true;
}

vector<P> make_cand(int r){
  vector<P> ret;
  for(int x=-r;x<=r;x++){
    double y = sqrt(r*r - x*x);
    if (abs(floor(y)-y)<eps){
      if (y>0.5){
	ret.pb(P(x,(int)y));
	ret.pb(P(x,(int)-y));
      }else ret.pb(P(x,(int)y));
    }
  }
  return ret;
}

int ans;
P ori(0,0);
void search(int n,int now,int m,int *len,int *num,P *in,vector<P>*cand){
  if (!isok(now,in))return;

  if (n == now){
    int index=-1;
    rep(i,m){
      if (num[i] != 0){index=len[i];}
    }
    if (abs(dist(in[now-1])-index)<eps ){
      int tmp = PolygonArea(in,now);
      if (isok(n,in))ans=max(ans,tmp);
    }
    return;
  }

  rep(i,m){
    if (num[i] == 0)continue;
    rep(j,cand[i].size()){
      num[i]--;
      in[now].real()=in[now-1].real()+cand[i][j].real();
      in[now].imag()=in[now-1].imag()+cand[i][j].imag();
      search(n,now+1,m,len,num,in,cand);
      num[i]++;
    }
  }
}



main(){
  int n;
  while(cin>>n && n){
    int r[n];
    int num[100];
    int len[100];
    int p=0;
    P in[10];
    vector<P> cand[10];
    
    ans = -1;

    
    rep(i,n){
      cin>>r[i];
    }
    sort(r,r+n);
    in[0]=ori;


    for(int i=0;i<n;i++){
      len[p]=r[i];
      num[p]=0;
      while(i<n && r[i] == r[p]){
	num[p]++;
	i++;
      }
      p++;
      i--;
    }
    

    rep(i,p){
      cand[i]=make_cand(len[i]);
    }
    
    rep(i,cand[p-1].size()){
      in[1]=cand[p-1][i];
      num[p-1]--;
      search(n,2,p,len,num,in,cand);
      num[p-1]++;
    }
    cout << ans << endl;
  }
}

Compiler output:
a.cc: In function 'void search(int, int, int, int*, int*, P*, std::vector<std::complex<int> >*)':
a.cc:116:19: error: lvalue required as left operand of assignment
  116 |       in[now].real()=in[now-1].real()+cand[i][j].real();
      |       ~~~~~~~~~~~~^~
a.cc:117:19: error: lvalue required as left operand of assignment
  117 |       in[now].imag()=in[now-1].imag()+cand[i][j].imag();
      |       ~~~~~~~~~~~~^~
a.cc: At global scope:
a.cc:126:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  126 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:142:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
  142 |     sort(r,r+n);
      |     ^~~~
      |     sqrt