//Tanuj Khattar
#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
const int INF = 1e9;
namespace SuffixTree{
  const int MAXN = 1.2e6;
  const int dollar = 257;
  int s[MAXN];
  map<int, int> to[MAXN];
  int len[MAXN]={INF}, fpos[MAXN], link[MAXN],suff[MAXN],par[MAXN];
  int node, pos, remain;
  int sz = 1, n = 0;
  int make_node(int _pos, int _len,int _par){
    fpos[sz] =  _pos;
    len [sz] = _len;
    suff[sz] = n - remain;
    par[sz] = _par;
    return sz++;
  }
  void go_edge(){
    while(pos > len[to[node][s[n - pos]]]){
      node = to[node][s[n - pos]];
      pos -= len[node];
    }
  }
  void add_letter(int c){
    s[n++] = c;int last = 0;
    for(remain++,pos++;pos > 0;remain--){
      go_edge();
      int edge = s[n - pos];
      int &v = to[node][edge];
      int t = s[fpos[v] + pos - 1];
      if(v == 0){
        v = make_node(n - pos, INF,node);
        link[last] = node;
        last = 0;
      }
      else if(t == c){
        link[last] = node;
        return;
      }
      else{
        int u = make_node(fpos[v], pos - 1,node);
        to[u][c] = make_node(n - 1, INF,u);
        to[u][t] = v;par[v] = u;
        fpos[v] += pos - 1;
        len [v] -= pos - 1;
        v = u;
        link[last] = u;
        last = u;
      }
      if(node == 0) pos--;
      else node = link[node];
    }
  }
}
const int N = int(1.2e6)+10;
int cost[N],idx[N],len,dollar[N];
LL sum[N];
char s[N];
LL ans;
void dfs(int x,int clen = 0/*,string s = ""*/){
  sum[x] = (SuffixTree::to[x].empty() ? cost[idx[SuffixTree::suff[x]]] : 0);
  for(auto it : SuffixTree::to[x]){
    int y = it.S,l = SuffixTree::fpos[y], r = min(len-1,l + SuffixTree::len[y] - 1);
    if(clen < 0)dfs(y,clen);
    else if(dollar[l] <= r)
      dfs(y,-INF),ans = max(ans,sum[y] * (dollar[l] - l + (dollar[l] > l ? clen : 0 )));
    else dfs(y,clen + r - l + 1);
    sum[x] += sum[y];
  }
  if(clen >= 0)
    ans = max(ans,sum[x] * clen);
}
int main()
{
  int n;si(n);
  int prv = 0;
  REP(i,n){
    scanf("%s",s);
    for(char *c = s;*c;c++)
      SuffixTree::add_letter(*c),idx[len++] = i;
    SuffixTree::add_letter(SuffixTree::dollar + i);
    idx[len++] = i;
    FOR(j,prv,len)dollar[j] = len - 1;
    prv = len;
  }
  REP(i,n)si(cost[i]);
  dfs(0);
  lldout(ans);
}


//Tanuj Khattar
#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
const int INF = 1e9;
namespace SuffixTree{
  const int MAXN = 2e6;
  const int dollar = 257;
  int s[MAXN];
  map<int, int> to[MAXN];
  int len[MAXN]={INF}, fpos[MAXN], link[MAXN],suff[MAXN],par[MAXN];
  int node, pos, remain;
  int sz = 1, n = 0;
  int make_node(int _pos, int _len,int _par){
    fpos[sz] =  _pos;
    len [sz] = _len;
    suff[sz] = n - remain;
    par[sz] = _par;
    return sz++;
  }
  void go_edge(){
    while(pos > len[to[node][s[n - pos]]]){
      node = to[node][s[n - pos]];
      pos -= len[node];
    }
  }
  void add_letter(int c){
    s[n++] = c;int last = 0;
    for(remain++,pos++;pos > 0;remain--){
      go_edge();
      int edge = s[n - pos];
      int &v = to[node][edge];
      int t = s[fpos[v] + pos - 1];
      if(v == 0){
        v = make_node(n - pos, INF,node);
        link[last] = node;
        last = 0;
      }
      else if(t == c){
        link[last] = node;
        return;
      }
      else{
        int u = make_node(fpos[v], pos - 1,node);
        to[u][c] = make_node(n - 1, INF,u);
        to[u][t] = v;par[v] = u;
        fpos[v] += pos - 1;
        len [v] -= pos - 1;
        v = u;
        link[last] = u;
        last = u;
      }
      if(node == 0) pos--;
      else node = link[node];
    }
  }
}
const int N = int(2e6)+10;
int cost[N],idx[N],len,dollar[N];
LL sum[N];
char s[N];
LL ans;
void dfs(int x,int clen = 0){
  sum[x] = (SuffixTree::to[x].empty() ? cost[idx[SuffixTree::suff[x]]] : 0);
  for(auto it : SuffixTree::to[x]){
    int y = it.S,l = SuffixTree::fpos[y], r = l + SuffixTree::len[y] - 1;
    if(clen < 0)dfs(y,clen);
    else if(dollar[l] <= r)
      dfs(y,-INF),ans = max(ans,sum[y] * (clen + dollar[l] - l));
    else dfs(y,clen + r - l + 1);
    sum[x] += sum[y];
  }
  if(clen >= 0)
    ans = max(ans,sum[x] * clen);
}
int main()
{
  int n;si(n);
  int prv = 0;
  REP(i,n){
    scanf("%s",s);
    for(char *c = s;*c;c++)
      SuffixTree::add_letter(*c),idx[len++] = i;
    SuffixTree::add_letter(SuffixTree::dollar + i);
    idx[len++] = i;
    FOR(j,prv,len)dollar[j] = len - 1;
    prv = len;
  }
  REP(i,n)si(cost[i]);
  dfs(0);
  lldout(ans);
}


//Tanuj Khattar
#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
const int INF = 1e9;
namespace SuffixTree{
  const int MAXN = 2e6;
  const int dollar = 257;
  int s[MAXN];
  map<int, int> to[MAXN];
  int len[MAXN]={INF}, fpos[MAXN], link[MAXN],suff[MAXN],par[MAXN];
  int node, pos, remain;
  int sz = 1, n = 0;
  int make_node(int _pos, int _len,int _par){
    fpos[sz] =  _pos;
    len [sz] = _len;
    suff[sz] = n - remain;
    par[sz] = _par;
    return sz++;
  }
  void go_edge(){
    while(pos > len[to[node][s[n - pos]]]){
      node = to[node][s[n - pos]];
      pos -= len[node];
    }
  }
  void add_letter(int c){
    s[n++] = c;int last = 0;
    for(remain++,pos++;pos > 0;remain--){
      go_edge();
      int edge = s[n - pos];
      int &v = to[node][edge];
      int t = s[fpos[v] + pos - 1];
      if(v == 0){
        v = make_node(n - pos, INF,node);
        link[last] = node;
        last = 0;
      }
      else if(t == c){
        link[last] = node;
        return;
      }
      else{
        int u = make_node(fpos[v], pos - 1,node);
        to[u][c] = make_node(n - 1, INF,u);
        to[u][t] = v;par[v] = u;
        fpos[v] += pos - 1;
        len [v] -= pos - 1;
        v = u;
        link[last] = u;
        last = u;
      }
      if(node == 0) pos--;
      else node = link[node];
    }
  }
}
const int N = int(2e6)+10;
int cost[N],idx[N],len,dollar[N];
LL sum[N];
char s[N];
LL ans;
void dfs(int x,int clen = 0/*,string s = ""*/){
  sum[x] = (SuffixTree::to[x].empty() ? cost[idx[SuffixTree::suff[x]]] : 0);
  for(auto it : SuffixTree::to[x]){
    int y = it.S,l = SuffixTree::fpos[y], r = min(len-1,l + SuffixTree::len[y] - 1);
    if(clen < 0)dfs(y,clen);
    else if(dollar[l] <= r)
      dfs(y,-INF),ans = max(ans,sum[y] * (dollar[l] - l + (dollar[l] > l ? clen : 0 )));
    else dfs(y,clen + r - l + 1);
    sum[x] += sum[y];
  }
  if(clen >= 0)
    ans = max(ans,sum[x] * clen);
}
int main()
{
  int n;si(n);
  int prv = 0;
  REP(i,n){
    scanf("%s",s);
    for(char *c = s;*c;c++)
      SuffixTree::add_letter(*c),idx[len++] = i;
    SuffixTree::add_letter(SuffixTree::dollar + i);
    idx[len++] = i;
    FOR(j,prv,len)dollar[j] = len - 1;
    prv = len;
  }
  REP(i,n)si(cost[i]);
  dfs(0);
  lldout(ans);
}


//Tanuj Khattar
#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
namespace SuffixTree{
  const int INF = 1e9;
  const int MAXN = 6e5 + 10;
  const int dollar = 257;
  int s[MAXN];
  map<int, int> to[MAXN];
  int len[MAXN]={INF}, fpos[MAXN], link[MAXN],suff[MAXN],par[MAXN];
  int node, pos, remain;
  int sz = 1, n = 0;
  int make_node(int _pos, int _len,int _par){
    fpos[sz] =  _pos;
    len [sz] = _len;
    suff[sz] = n - remain;
    par[sz] = _par;
    return sz++;
  }
  void go_edge(){
    while(pos > len[to[node][s[n - pos]]]){
      node = to[node][s[n - pos]];
      pos -= len[node];
    }
  }
  void add_letter(int c){
    s[n++] = c;int last = 0;
    for(remain++,pos++;pos > 0;remain--){
      go_edge();
      int edge = s[n - pos];
      int &v = to[node][edge];
      int t = s[fpos[v] + pos - 1];
      if(v == 0){
        v = make_node(n - pos, INF,node);
        link[last] = node;
        last = 0;
      }
      else if(t == c){
        link[last] = node;
        return;
      }
      else{
        int u = make_node(fpos[v], pos - 1,node);
        to[u][c] = make_node(n - 1, INF,u);
        to[u][t] = v;par[v] = u;
        fpos[v] += pos - 1;
        len [v] -= pos - 1;
        v = u;
        link[last] = u;
        last = u;
      }
      if(node == 0) pos--;
      else node = link[node];
    }
  }
}
const int N = int(6e5)+10;
int cost[N],idx[N],len;
LL sum[N];
char s[N];
LL ans;
void dfs(int x,int clen = 0){
  sum[x] = (SuffixTree::to[x].empty() ? cost[idx[SuffixTree::suff[x]]] : 0);
  for(auto it : SuffixTree::to[x]){
    int y = it.S;
    dfs(y,clen + SuffixTree::len[y]);
    sum[x] += sum[y];
  }
  if(!SuffixTree::to[x].empty())
    ans = max(ans,sum[x] * clen);
}
int main()
{
  int n;si(n);
  REP(i,n){
    scanf("%s",s);
    for(char *c = s;*c;c++)
      SuffixTree::add_letter(*c),idx[len++] = i;
    SuffixTree::add_letter(SuffixTree::dollar + i);
    idx[len++] = i;
  }
  REP(i,n)si(cost[i]);
  dfs(0);
  lldout(ans);
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e6+5,LG=20,SM=600,inf=1e18+5;
ll mod=1e9+7;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll crr[LG][M];
ll suf[M];
str s[M];
ll n;
str sall;
ll arzesh[M],psarzesh[M];

ll gi=0;

ll ms[M],lms[M],rms[M];

bool cmp(ll i,ll j){
  if (crr[gi][i]!=crr[gi][j]) return crr[gi][i]<crr[gi][j];
  ll ri=rms[ms[i]];
  ll rj=rms[ms[j]];
  i+=(1<<gi);
  j+=(1<<gi);
  //ER(i);ER(j);ER(ms[i]);ER(ms[j]);ER(rms[ms[i]]);ER(rms[ms[j]]);
  if (i>=ri) return 0;
  if (j>=rj) return 1;
  return crr[gi][i]<crr[gi][j];
}

ll lcp[M];

ll lcpf(ll i,ll j){
  ll res=0;
  Ford(r,LG-1,0){
    if (crr[r][i]==crr[r][j]){
      res+=(1<<r);
      i+=(1<<r);
      j+=(1<<r);
    }
  }
  return res;
}

ll lo[M],hi[M];

ll mxvalid(ll i){
  return rms[ms[i]]-i;
}

int main(){
  ios::sync_with_stdio(0);
  cin >> n;
  ll res=0;
  For(i,0,n){
    cin >> s[i];
    lms[i]=SZ(sall);
    For(j,SZ(sall),SZ(sall)+SZ(s[i]))
    {
      ms[j]=i;
    }
    sall+=s[i];
    rms[i]=SZ(sall);
  }
  //ER(sall);
  For(i,0,n){
    cin >> arzesh[i];
    smax(res,SZ(s[i])*arzesh[i]);
  }
  ll nall=SZ(sall);
  iota(suf,suf+nall,0);
  For(i,0,nall){
    crr[0][i]=sall[i];
  }
  For(i,1,LG){
    gi=i-1;
    //For(j,0,nall) cout << crr[i-1][j] << ' ';
    //cout << '\n';
    sort(suf,suf+nall,cmp);
    crr[i][suf[0]]=0;
    For(j,1,nall){
      crr[i][suf[j]]=crr[i][suf[j-1]]+cmp(suf[j-1],suf[j]);
    }
  }
  /*For(i,0,nall){
    ER(suf[i]);
    }*/
  For(i,0,nall-1){
    lcp[i]=lcpf(suf[i],suf[i+1]);
    smin(lcp[i],mxvalid(suf[i]));
    smin(lcp[i],mxvalid(suf[i+1]));
    //ER(suf[i]);
    //ER(lcp[i]);
  }
  For(i,0,nall){
    psarzesh[i+1]=psarzesh[i]+arzesh[ms[suf[i]]];
    //ER(psarzesh[i+1]);
  }
  vll st;
  For(i,0,nall-1){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) lo[i]=st.back()+1;
    st.PB(i);
  }
  st.clear();
  Ford(i,nall-2,0){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) hi[i]=st.back()+1;
    else hi[i]=nall;
    st.PB(i);
  }
  For(i,0,nall-1){
    smax(res,(psarzesh[hi[i]]-psarzesh[lo[i]])*lcp[i]);
  }
  RET(res);
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=5e5+5,LG=20,SM=600,inf=1e18+5;
ll mod=1e9+7;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll crr[LG][M];
ll suf[M];
str s[M];
ll n;
str sall;
ll arzesh[M],psarzesh[M];

ll gi=0;

ll ms[M],lms[M],rms[M];

bool cmp(ll i,ll j){
  if (crr[gi][i]!=crr[gi][j]) return crr[gi][i]<crr[gi][j];
  ll ri=rms[ms[i]];
  ll rj=rms[ms[j]];
  i+=(1<<gi);
  j+=(1<<gi);
  //ER(i);ER(j);ER(ms[i]);ER(ms[j]);ER(rms[ms[i]]);ER(rms[ms[j]]);
  if (i>=ri) return 0;
  if (j>=rj) return 1;
  return crr[gi][i]<crr[gi][j];
}

ll lcp[M];

ll lcpf(ll i,ll j){
  ll res=0;
  Ford(r,LG-1,0){
    if (crr[r][i]==crr[r][j]){
      res+=(1<<r);
      i+=(1<<r);
      j+=(1<<r);
    }
  }
  return res;
}

ll lo[M],hi[M];

ll mxvalid(ll i){
  return rms[ms[i]]-i;
}

int main(){
  ios::sync_with_stdio(0);
  cin >> n;
  ll res=0;
  For(i,0,n){
    cin >> s[i];
    lms[i]=SZ(sall);
    For(j,SZ(sall),SZ(sall)+SZ(s[i]))
    {
      ms[j]=i;
    }
    sall+=s[i];
    rms[i]=SZ(sall);
  }
  //ER(sall);
  For(i,0,n){
    cin >> arzesh[i];
    smax(res,SZ(s[i])*arzesh[i]);
  }
  ll nall=SZ(sall);
  iota(suf,suf+nall,0);
  For(i,0,nall){
    crr[0][i]=sall[i];
  }
  For(i,1,LG){
    gi=i-1;
    //For(j,0,nall) cout << crr[i-1][j] << ' ';
    //cout << '\n';
    sort(suf,suf+nall,cmp);
    crr[i][suf[0]]=0;
    For(j,1,nall){
      crr[i][suf[j]]=crr[i][suf[j-1]]+cmp(suf[j-1],suf[j]);
    }
  }
  /*For(i,0,nall){
    ER(suf[i]);
    }*/
  For(i,0,nall-1){
    lcp[i]=lcpf(suf[i],suf[i+1]);
    smin(lcp[i],mxvalid(suf[i]));
    smin(lcp[i],mxvalid(suf[i+1]));
    //ER(suf[i]);
    //ER(lcp[i]);
  }
  For(i,0,nall){
    psarzesh[i+1]=psarzesh[i]+arzesh[ms[suf[i]]];
    //ER(psarzesh[i+1]);
  }
  vll st;
  For(i,0,nall-1){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) lo[i]=st.back()+1;
    st.PB(i);
  }
  st.clear();
  Ford(i,nall-2,0){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) hi[i]=st.back()+1;
    else hi[i]=nall;
    st.PB(i);
  }
  For(i,0,nall-1){
    smax(res,(psarzesh[hi[i]]-psarzesh[lo[i]])*lcp[i]);
  }
  RET(res);
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e6+5,LG=20,SM=600,inf=1e18+5;
ll mod=1e9+7;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll crr[LG][M];
ll suf[M];
str s[M];
ll n;
str sall;
ll arzesh[M],psarzesh[M];

ll gi=0;

ll ms[M],lms[M],rms[M];

bool cmp(ll i,ll j){
  if (crr[gi][i]!=crr[gi][j]) return crr[gi][i]<crr[gi][j];
  ll ri=rms[ms[i]];
  ll rj=rms[ms[j]];
  i+=(1<<gi);
  j+=(1<<gi);
  //ER(i);ER(j);ER(ms[i]);ER(ms[j]);ER(rms[ms[i]]);ER(rms[ms[j]]);
  if (i>=ri) return 0;
  if (j>=rj) return 1;
  return crr[gi][i]<crr[gi][j];
}

ll lcp[M];

ll lcpf(ll i,ll j){
  ll res=0;
  Ford(r,LG-1,0){
    if (crr[r][i]==crr[r][j]){
      res+=(1<<r);
      i+=(1<<r);
      j+=(1<<r);
    }
  }
  return res;
}

ll lo[M],hi[M];

ll mxvalid(ll i){
  return rms[ms[i]]-i;
}

int main(){
  ios::sync_with_stdio(0);
  cin >> n;
  ll res=0;
  For(i,0,n){
    cin >> s[i];
    lms[i]=SZ(sall);
    For(j,SZ(sall),SZ(sall)+SZ(s[i]))
    {
      ms[j]=i;
    }
    sall+=s[i];
    rms[i]=SZ(sall);
  }
  //ER(sall);
  ll sigmaarzesh=0;
  For(i,0,n){
    cin >> arzesh[i];
    sigmaarzesh+=arzesh[i];
    smax(res,SZ(s[i])*arzesh[i]);
  }
  if (!sigmaarzesh) RET(0);
  ll nall=SZ(sall);
  iota(suf,suf+nall,0);
  For(i,0,nall){
    crr[0][i]=sall[i];
  }
  For(i,1,LG){
    gi=i-1;
    //For(j,0,nall) cout << crr[i-1][j] << ' ';
    //cout << '\n';
    sort(suf,suf+nall,cmp);
    crr[i][suf[0]]=0;
    For(j,1,nall){
      crr[i][suf[j]]=crr[i][suf[j-1]]+cmp(suf[j-1],suf[j]);
    }
  }
  /*For(i,0,nall){
    ER(suf[i]);
    }*/
  For(i,0,nall-1){
    lcp[i]=lcpf(suf[i],suf[i+1]);
    smin(lcp[i],mxvalid(suf[i]));
    smin(lcp[i],mxvalid(suf[i+1]));
    //ER(suf[i]);
    //ER(lcp[i]);
  }
  For(i,0,nall){
    psarzesh[i+1]=psarzesh[i]+arzesh[ms[suf[i]]];
    //ER(psarzesh[i+1]);
  }
  vll st;
  For(i,0,nall-1){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) lo[i]=st.back()+1;
    st.PB(i);
  }
  st.clear();
  Ford(i,nall-2,0){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) hi[i]=st.back()+1;
    else hi[i]=nall;
    st.PB(i);
  }
  For(i,0,nall-1){
    smax(res,(psarzesh[hi[i]]-psarzesh[lo[i]])*lcp[i]);
  }
  RET(res);
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e6+5,LG=20,SM=600,inf=1e18+5;
ll mod=1e9+7;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll crr[LG][M];
ll suf[M];
str s[M];
ll n;
str sall;
ll arzesh[M],psarzesh[M];

ll gi=0;

ll ms[M],lms[M],rms[M];

bool cmp(ll i,ll j){
  if (crr[gi][i]!=crr[gi][j]) return crr[gi][i]<crr[gi][j];
  ll ri=rms[ms[i]];
  ll rj=rms[ms[j]];
  i+=(1<<gi);
  j+=(1<<gi);
  //ER(i);ER(j);ER(ms[i]);ER(ms[j]);ER(rms[ms[i]]);ER(rms[ms[j]]);
  if (i>=ri) return 0;
  if (j>=rj) return 1;
  return crr[gi][i]<crr[gi][j];
}

ll lcp[M];

ll lcpf(ll i,ll j){
  ll res=0;
  Ford(r,LG-1,0){
    if (crr[r][i]==crr[r][j]){
      res+=(1<<r);
      i+=(1<<r);
      j+=(1<<r);
    }
  }
  return res;
}

ll lo[M],hi[M];

ll mxvalid(ll i){
  return rms[ms[i]]-i;
}

int main(){
  ios::sync_with_stdio(0);
  cin >> n;
  ll res=0;
  For(i,0,n){
    cin >> s[i];
    lms[i]=SZ(sall);
    For(j,SZ(sall),SZ(sall)+SZ(s[i]))
    {
      ms[j]=i;
    }
    sall+=s[i];
    rms[i]=SZ(sall);
  }
  //ER(sall);
  ll sigmaarzesh=0;
  For(i,0,n){
    cin >> arzesh[i];
    sigmaarzesh+=arzesh[i];
  }
  if (!sigmaarzesh) RET(0);
  ll nall=SZ(sall);
  iota(suf,suf+nall,0);
  For(i,0,nall){
    crr[0][i]=sall[i];
  }
  For(i,1,LG){
    gi=i-1;
    //For(j,0,nall) cout << crr[i-1][j] << ' ';
    //cout << '\n';
    sort(suf,suf+nall,cmp);
    crr[i][suf[0]]=0;
    For(j,1,nall){
      crr[i][suf[j]]=crr[i][suf[j-1]]+cmp(suf[j-1],suf[j]);
    }
  }
  /*For(i,0,nall){
    ER(suf[i]);
    }*/
  For(i,0,nall-1){
    lcp[i]=lcpf(suf[i],suf[i+1]);
    smin(lcp[i],mxvalid(suf[i]));
    smin(lcp[i],mxvalid(suf[i+1]));
    //ER(suf[i]);
    //ER(lcp[i]);
  }
  For(i,0,nall){
    psarzesh[i+1]=psarzesh[i]+arzesh[ms[suf[i]]];
    //ER(psarzesh[i+1]);
  }
  vll st;
  For(i,0,nall-1){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) lo[i]=st.back()+1;
    st.PB(i);
  }
  st.clear();
  Ford(i,nall-2,0){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) hi[i]=st.back()+1;
    else hi[i]=nall;
    st.PB(i);
  }
  For(i,0,nall-1){
    smax(res,(psarzesh[hi[i]]-psarzesh[lo[i]])*lcp[i]);
  }
  RET(res);
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=5e5+5,LG=20,SM=600,inf=1e18+5;
ll mod=1e9+7;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll crr[LG][M];
ll suf[M];
str s[M];
ll n;
str sall;
ll arzesh[M],psarzesh[M];

ll gi=0;

ll ms[M],lms[M],rms[M];

bool cmp(ll i,ll j){
  if (crr[gi][i]!=crr[gi][j]) return crr[gi][i]<crr[gi][j];
  ll ri=rms[ms[i]];
  ll rj=rms[ms[j]];
  i+=(1<<gi);
  j+=(1<<gi);
  //ER(i);ER(j);ER(ms[i]);ER(ms[j]);ER(rms[ms[i]]);ER(rms[ms[j]]);
  if (i>=ri) return 0;
  if (j>=rj) return 1;
  return crr[gi][i]<crr[gi][j];
}

ll lcp[M];

ll lcpf(ll i,ll j){
  ll res=0;
  Ford(r,LG-1,0){
    if (crr[r][i]==crr[r][j]){
      res+=(1<<r);
      i+=(1<<r);
      j+=(1<<r);
    }
  }
  return res;
}

ll lo[M],hi[M];

ll mxvalid(ll i){
  return rms[ms[i]]-i;
}

int main(){
  ios::sync_with_stdio(0);
  cin >> n;
  ll res=0;
  For(i,0,n){
    cin >> s[i];
    lms[i]=SZ(sall);
    For(j,SZ(sall),SZ(sall)+SZ(s[i]))
    {
      ms[j]=i;
    }
    sall+=s[i];
    rms[i]=SZ(sall);
  }
  //ER(sall);
  For(i,0,n){
    cin >> arzesh[i];
    smax(res,SZ(s[i])*arzesh[i]);
  }
  ll nall=SZ(sall);
  iota(suf,suf+nall,0);
  For(i,0,nall){
    crr[0][i]=sall[i];
  }
  For(i,1,LG){
    gi=i-1;
    sort(suf,suf+nall,cmp);
    crr[i][suf[0]]=0;
    For(j,1,nall){
      crr[i][suf[j]]=crr[i][suf[j-1]]+cmp(suf[j-1],suf[j]);
    }
  }
  /*For(i,0,nall){
    ER(suf[i]);
    }*/
  For(i,0,nall-1){
    lcp[i]=lcpf(suf[i],suf[i+1]);
    //ER(lcp[i]);
  }
  For(i,0,nall){
    psarzesh[i+1]=psarzesh[i]+arzesh[ms[suf[i]]];
    //ER(psarzesh[i+1]);
  }
  vll st;
  For(i,0,nall-1){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) lo[i]=st.back()+1;
    st.PB(i);
  }
  st.clear();
  Ford(i,nall-2,0){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) hi[i]=st.back()+1;
    else hi[i]=nall;
    st.PB(i);
  }
  For(i,0,nall-1){
    smax(res,(psarzesh[hi[i]]-psarzesh[lo[i]])*lcp[i]);
  }
  RET(res);
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e6+5,LG=20,SM=600,inf=1e18+5;
ll mod=1e9+7;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll crr[LG][M];
ll suf[M];
str s[M];
ll n;
str sall;
ll arzesh[M],psarzesh[M];

ll gi=0;

ll ms[M],lms[M],rms[M];

bool cmp(ll i,ll j){
  if (crr[gi][i]!=crr[gi][j]) return crr[gi][i]<crr[gi][j];
  ll ri=rms[ms[i]];
  ll rj=rms[ms[j]];
  i+=(1<<gi);
  j+=(1<<gi);
  //ER(i);ER(j);ER(ms[i]);ER(ms[j]);ER(rms[ms[i]]);ER(rms[ms[j]]);
  if (i>=ri) return 0;
  if (j>=rj) return 1;
  return crr[gi][i]<crr[gi][j];
}

ll lcp[M];

ll lcpf(ll i,ll j){
  ll res=0;
  Ford(r,LG-1,0){
    if (crr[r][i]==crr[r][j]){
      res+=(1<<r);
      i+=(1<<r);
      j+=(1<<r);
    }
  }
  return res;
}

ll lo[M],hi[M];

ll mxvalid(ll i){
  return rms[ms[i]]-i;
}

int main(){
  ios::sync_with_stdio(0);
  cin >> n;
  ll res=0;
  For(i,0,n){
    cin >> s[i];
    lms[i]=SZ(sall);
    For(j,SZ(sall),SZ(sall)+SZ(s[i]))
    {
      ms[j]=i;
    }
    sall+=s[i];
    rms[i]=SZ(sall);
  }
  //ER(sall);
  ll sigmaarzesh=0;
  For(i,0,n){
    cin >> arzesh[i];
    sigmaarzesh+=arzesh[i];
  }
  if (!sigmaarzesh) RET(0);
  ll nall=SZ(sall);
  iota(suf,suf+nall,0);
  For(i,0,nall){
    crr[0][i]=sall[i];
  }
  For(i,1,LG){
    gi=i-1;
    //For(j,0,nall) cout << crr[i-1][j] << ' ';
    //cout << '\n';
    sort(suf,suf+nall,cmp);
    crr[i][suf[0]]=0;
    For(j,1,nall){
      crr[i][suf[j]]=crr[i][suf[j-1]]+cmp(suf[j-1],suf[j]);
    }
  }
  /*For(i,0,nall){
    ER(suf[i]);
    }*/
  For(i,0,nall-1){
    lcp[i]=lcpf(suf[i],suf[i+1]);
    smin(lcp[i],mxvalid(suf[i]));
    smin(lcp[i],mxvalid(suf[i+1]));
    //ER(suf[i]);
    //ER(lcp[i]);
  }
  if (mxvalid(suf[0])!=lcp[0]) smax(res,mxvalid(suf[0])*arzesh[ms[suf[0]]]);
  For(i,1,nall){
    if (lcp[i]!=mxvalid(suf[i]) && lcp[i-1]!=mxvalid(suf[i])){
      smax(res,mxvalid(suf[i])*arzesh[ms[suf[i]]]);
    }
  }
  For(i,0,nall){
    psarzesh[i+1]=psarzesh[i]+arzesh[ms[suf[i]]];
    //ER(psarzesh[i+1]);
  }
  vll st;
  For(i,0,nall-1){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) lo[i]=st.back()+1;
    st.PB(i);
  }
  st.clear();
  Ford(i,nall-2,0){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) hi[i]=st.back()+1;
    else hi[i]=nall;
    st.PB(i);
  }
  For(i,0,nall-1){
    smax(res,(psarzesh[hi[i]]-psarzesh[lo[i]])*lcp[i]);
  }
  RET(res);
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e6+5,LG=20,SM=600,inf=1e18+5;
ll mod=1e9+7;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll crr[LG][M];
ll suf[M];
str s[M];
ll n;
str sall;
ll arzesh[M],psarzesh[M];

ll gi=0;

ll ms[M],lms[M],rms[M];

bool cmp(ll i,ll j){
  if (crr[gi][i]!=crr[gi][j]) return crr[gi][i]<crr[gi][j];
  ll ri=rms[ms[i]];
  ll rj=rms[ms[j]];
  i+=(1<<gi);
  j+=(1<<gi);
  //ER(i);ER(j);ER(ms[i]);ER(ms[j]);ER(rms[ms[i]]);ER(rms[ms[j]]);
  if (i>=ri) return 0;
  if (j>=rj) return 1;
  return crr[gi][i]<crr[gi][j];
}

ll lcp[M];

ll lcpf(ll i,ll j){
  ll res=0;
  Ford(r,LG-1,0){
    if (crr[r][i]==crr[r][j]){
      res+=(1<<r);
      i+=(1<<r);
      j+=(1<<r);
    }
  }
  return res;
}

ll lo[M],hi[M];

ll mxvalid(ll i){
  return rms[ms[i]]-i;
}

int main(){
  ios::sync_with_stdio(0);
  cin >> n;
  ll res=0;
  For(i,0,n){
    cin >> s[i];
    lms[i]=SZ(sall);
    For(j,SZ(sall),SZ(sall)+SZ(s[i]))
    {
      ms[j]=i;
    }
    sall+=s[i];
    rms[i]=SZ(sall);
  }
  //ER(sall);
  ll sigmaarzesh=0;
  For(i,0,n){
    cin >> arzesh[i];
    sigmaarzesh+=arzesh[i];
  }
  if (!sigmaarzesh) RET(0);
  ll nall=SZ(sall);
  iota(suf,suf+nall,0);
  For(i,0,nall){
    crr[0][i]=sall[i];
  }
  For(i,1,LG){
    gi=i-1;
    //For(j,0,nall) cout << crr[i-1][j] << ' ';
    //cout << '\n';
    sort(suf,suf+nall,cmp);
    crr[i][suf[0]]=0;
    For(j,1,nall){
      crr[i][suf[j]]=crr[i][suf[j-1]]+cmp(suf[j-1],suf[j]);
    }
  }
  /*For(i,0,nall){
    ER(suf[i]);
    }*/
  For(i,0,nall-1){
    lcp[i]=lcpf(suf[i],suf[i+1]);
    smin(lcp[i],mxvalid(suf[i]));
    smin(lcp[i],mxvalid(suf[i+1]));
    //ER(suf[i]);
    //ER(lcp[i]);
  }
  if (mxvalid(suf[0])!=lcp[0]) smax(res,mxvaid(suf[0])*arzesh[ms[suf[0]]]);
  For(i,1,nall){
    if (lcp[i]!=mxvalid(suf[i]) && lcp[i-1]!=mxvalid(suf[i])){
      smax(res,mxvaid(suf[i])*arzesh[ms[suf[i]]]);
    }
  }
  For(i,0,nall){
    psarzesh[i+1]=psarzesh[i]+arzesh[ms[suf[i]]];
    //ER(psarzesh[i+1]);
  }
  vll st;
  For(i,0,nall-1){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) lo[i]=st.back()+1;
    st.PB(i);
  }
  st.clear();
  Ford(i,nall-2,0){
    while (SZ(st) && lcp[i]<=lcp[st.back()]){
      st.pop_back();
    }
    if (SZ(st)) hi[i]=st.back()+1;
    else hi[i]=nall;
    st.PB(i);
  }
  For(i,0,nall-1){
    smax(res,(psarzesh[hi[i]]-psarzesh[lo[i]])*lcp[i]);
  }
  RET(res);
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 100;

struct SuffixArray {
    int n;
    string s;
    vector<int> SA, RA, tempSA, tempRA, LCP, L;

    SuffixArray() {}
    SuffixArray(string st) {
        s = st;
        RA.clear();
        n = s.size();
        RA.resize(n + 1, 0);
        SA = tempSA = tempRA = LCP = RA;
        L.resize(N);
        BuildSA();
    }

    void BuildSA() {
        for (int i = 0; i < n; ++i) SA[i] = i, RA[i] = s[i];
        for (int k = 1; k <= n; k <<= 1) {
            radix_sort(k); radix_sort(0);
            for (int i = 1, r = 0; i < n; ++i) {
                if (getRA(SA[i - 1]) != getRA(SA[i]) || getRA(SA[i - 1] + k) != getRA(SA[i] + k)) ++r;
                tempRA[SA[i]] = r;
            }
            for (int i = 0; i < n; ++i) RA[i] = tempRA[i];
            if (RA[SA[n - 1]] == n - 1) break;
        }
        //
        for (int i = 0; i < n; ++i) RA[SA[i]] = i;
        for (int i = 0, k = 0; i < n; ++i) {
            if (RA[i] == n - 1) { k = 0; continue; }
            int j = SA[RA[i] + 1];
            while (max(i, j) + k < n && s[i + k] == s[j + k] && s[i + k] != '$') ++k;
            LCP[RA[i]] = k;
            if (k) --k;
        }
    }
private:
    inline int getRA(int i) { return i < n ? RA[i] : 0; }
    void radix_sort(int k) {
        for (int i = 0; i < N; ++i) L[i] = 0;
        for (int i = 0; i < n; ++i) L[getRA(i + k)]++;
        for (int i = 0, p = 0; i < N; ++i) {
            int x = L[i]; L[i] = p, p += x;
        }
        for (int i = 0; i < n; ++i) {
            int& x = L[getRA(SA[i] + k)];
            tempSA[x++] = SA[i];
        }
        for (int i = 0; i < n; ++i) SA[i] = tempSA[i];
    }
};

int id[N], c[N], sz[N];
long long sum[N];

int main() {
    long long ans = 0;
    string st;
    int n;
    cin >> n;
    int length = 0;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        sz[i + 1] = s.size();
        for (char c : s) {
            id[st.size()] = i + 1;
            st.push_back(c);
        }
        id[st.size()] = 0;
        st.push_back('$');
    }
    for (int i = 1; i <= n; ++i) {
        cin >> c[i];
        ans = max(ans, 1ll * c[i] * sz[i]);
    }
    //
    n = st.size() - 1;
    SuffixArray SA(st);
    // cout << st << '\n';
    // for (int i = 0; i <= n; ++i) cout << SA.SA[i] << ' '; cout << "SA\n";
    //for (int i = 0; i <= n; ++i) cout << SA.LCP[i] << ' '; cout << "LCP\n";
    //for (int i = 0; i <= n; ++i) cout << id[SA.SA[i]] << ' '; cout << "ID\n";
    for (int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1] + c[id[SA.SA[i]]];
    }
    //for (int i = 0; i <= n; ++i) cout << sum[i] << ' '; cout << "SUM\n";
    auto Sum = [&](int l, int r) { return sum[r] - sum[l - 1]; };
    int l = 0, r = 0, a = 0, b = 0;
    for (int i = 1; i <= n; ++i) {
        int lcp = n;
        for (int j = i + 1; j <= n; ++j) {
            lcp = min(lcp, SA.LCP[j - 1]);
            if (ans < 1ll * lcp * Sum(i, j)) {
                ans = 1ll * lcp * Sum(i, j);
                l = i, r = j;
                a = lcp, b = 1ll * sum[i - 1];
            }

        }
    }
    cout << ans;
    if (n == 1000) cout << ' ' << st.substr(l, r - l + 1);
    //cerr << '\n' << l << ' ' << r << ' ' << a << ' ' << b << ' ' << sum[r] << '\n';
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 100;

struct SuffixArray {
    int n;
    string s;
    vector<int> SA, RA, tempSA, tempRA, LCP, L;

    SuffixArray() {}
    SuffixArray(string st) {
        s = st;
        RA.clear();
        n = s.size();
        RA.resize(n + 1, 0);
        SA = tempSA = tempRA = LCP = RA;
        L.resize(N);
        BuildSA();
    }

    void BuildSA() {
        for (int i = 0; i < n; ++i) SA[i] = i, RA[i] = s[i];
        for (int k = 1; k <= n; k <<= 1) {
            radix_sort(k); radix_sort(0);
            for (int i = 1, r = 0; i < n; ++i) {
                if (getRA(SA[i - 1]) != getRA(SA[i]) || getRA(SA[i - 1] + k) != getRA(SA[i] + k)) ++r;
                tempRA[SA[i]] = r;
            }
            for (int i = 0; i < n; ++i) RA[i] = tempRA[i];
            if (RA[SA[n - 1]] == n - 1) break;
        }
        //
        for (int i = 0; i < n; ++i) RA[SA[i]] = i;
        for (int i = 0, k = 0; i < n; ++i) {
            if (RA[i] == n - 1) { k = 0; continue; }
            int j = SA[RA[i] + 1];
            while (max(i, j) + k < n && s[i + k] == s[j + k] && s[i + k] != '$') ++k;
            LCP[RA[i]] = k;
            if (k) --k;
        }
    }
private:
    inline int getRA(int i) { return i < n ? RA[i] : 0; }
    void radix_sort(int k) {
        for (int i = 0; i < N; ++i) L[i] = 0;
        for (int i = 0; i < n; ++i) L[getRA(i + k)]++;
        for (int i = 0, p = 0; i < N; ++i) {
            int x = L[i]; L[i] = p, p += x;
        }
        for (int i = 0; i < n; ++i) {
            int& x = L[getRA(SA[i] + k)];
            tempSA[x++] = SA[i];
        }
        for (int i = 0; i < n; ++i) SA[i] = tempSA[i];
    }
};

int id[N], c[N], sz[N];
long long sum[N];

int main() {
    long long ans = 0;
    string st;
    int n;
    cin >> n;
    int length = 0;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        sz[i + 1] = s.size();
        for (char c : s) {
            id[st.size()] = i + 1;
            st.push_back(c);
        }
        id[st.size()] = 0;
        st.push_back('$');
    }
    for (int i = 1; i <= n; ++i) {
        cin >> c[i];
        ans = max(ans, 1ll * c[i] * sz[i]);
    }
    //
    n = st.size() - 1;
    SuffixArray SA(st);
    // cout << st << '\n';
    // for (int i = 0; i <= n; ++i) cout << SA.SA[i] << ' '; cout << "SA\n";
    //for (int i = 0; i <= n; ++i) cout << SA.LCP[i] << ' '; cout << "LCP\n";
    //for (int i = 0; i <= n; ++i) cout << id[SA.SA[i]] << ' '; cout << "ID\n";
    for (int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1] + c[id[SA.SA[i]]];
    }
    //for (int i = 0; i <= n; ++i) cout << sum[i] << ' '; cout << "SUM\n";
    auto Sum = [&](int l, int r) { return sum[r] - sum[l - 1]; };
    vector<pair<int, long long> > hull(n + 1); // store <LCP, minSum>
    int sze = 1, le = 0;
    hull[0] = {0, 0};
    for (int i = 2; i <= n; ++i) {
        pair<int, long long> best = {SA.LCP[i - 1], sum[i - 2]};
        while (sze > 1 && sze > le  && hull[sze - 1].first >= best.first) {
            best.second = min(best.second, hull[sze - 1].second);
            sze--;
        }
        auto a = [&] (pair<int, long long> x) { return x.first; };
        auto b = [&] (pair<int, long long> x) { return -x.second * x.first;};
        auto Eval = [&] (pair<int, long long> line, long long x) { return a(line) * x + b(line); };
        while (sze > 1 && sze > le &&
            ((b(best) - b(hull[sze - 2])) * (a(hull[sze - 2]) - a(hull[sze - 1]))
        <= (b(hull[sze - 1]) - b(hull[sze - 2]) * (a(hull[sze - 2]) - a(best))))) {
            --sze;
        }
        hull[sze++] = best;
        // cerr << "Hull now: \n";
        // for (int i = )
        //cerr << i << " = [" << a(best) << ',' << b(best) << "]\n";
        // (sumi - best.second) * best.first
        // sum * best.first - best.second * best.first
        auto Query = [&] (long long x) {
            //cerr << "Query " << x << '\n';
            while (le + 1 < sze && x * (a(hull[le + 1]) - a(hull[le])) >= (b(hull[le]) - b(hull[le + 1]))) ++le;
            //cerr << "OPT " << le << " = [" << a(hull[le]) << ',' << b(hull[le]) << "]\n";
            //cerr << "Res = " << Eval(hull[le], x) << '\n';
            return Eval(hull[le], x);
        };
        ans = max(ans, Query(sum[i]));
    }
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 100;

struct SuffixArray {
    int n;
    string s;
    vector<int> SA, RA, tempSA, tempRA, LCP, L;

    SuffixArray() {}
    SuffixArray(string st) {
        s = st;
        RA.clear();
        n = s.size();
        RA.resize(n + 1, 0);
        SA = tempSA = tempRA = LCP = RA;
        L.resize(N);
        BuildSA();
    }

    void BuildSA() {
        for (int i = 0; i < n; ++i) SA[i] = i, RA[i] = s[i];
        for (int k = 1; k <= n; k <<= 1) {
            radix_sort(k); radix_sort(0);
            for (int i = 1, r = 0; i < n; ++i) {
                if (getRA(SA[i - 1]) != getRA(SA[i]) || getRA(SA[i - 1] + k) != getRA(SA[i] + k)) ++r;
                tempRA[SA[i]] = r;
            }
            for (int i = 0; i < n; ++i) RA[i] = tempRA[i];
            if (RA[SA[n - 1]] == n - 1) break;
        }
        //
        for (int i = 0; i < n; ++i) RA[SA[i]] = i;
        for (int i = 0, k = 0; i < n; ++i) {
            if (RA[i] == n - 1) { k = 0; continue; }
            int j = SA[RA[i] + 1];
            while (max(i, j) + k < n && s[i + k] == s[j + k] && s[i + k] != '$') ++k;
            LCP[RA[i]] = k;
            if (k) --k;
        }
    }
private:
    inline int getRA(int i) { return i < n ? RA[i] : 0; }
    void radix_sort(int k) {
        for (int i = 0; i < N; ++i) L[i] = 0;
        for (int i = 0; i < n; ++i) L[getRA(i + k)]++;
        for (int i = 0, p = 0; i < N; ++i) {
            int x = L[i]; L[i] = p, p += x;
        }
        for (int i = 0; i < n; ++i) {
            int& x = L[getRA(SA[i] + k)];
            tempSA[x++] = SA[i];
        }
        for (int i = 0; i < n; ++i) SA[i] = tempSA[i];
    }
};

int id[N], c[N], d[N], END[N];
long long sum[N], cost[N];
int par[N][21];

vector<int> e[N];

long long dfs(int u) {
    long long ans = 0;
    for (int v : e[u]) {
        ans = max(ans, dfs(v));
        cost[u] += cost[v];
    }
    ans = max(ans, cost[u] * d[u]);
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    long long ans = 0;
    string st;
    int n;
    cin >> n;
    int length = 0;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        for (char c : s) {
            id[st.size()] = i + 1;
            st.push_back(c);
        }
        END[i + 1] = st.size();
        id[st.size()] = 0;
        st.push_back('$');
    }
    for (int i = 1; i <= n; ++i) {
        cin >> c[i];
    }
    n = st.size() - 1;
    //cerr << n << '\n';
    SuffixArray SA(st);
    for (int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1] + c[id[SA.SA[i]]];
    }
    // cout << st << '\n';
    // for (int i = 0; i <= n; ++i) cout << SA.SA[i] << ' '; cout << "SA\n";
    // for (int i = 0; i <= n; ++i) cout << SA.LCP[i] << ' '; cout << "LCP\n";
    // for (int i = 0; i <= n; ++i) cout << id[SA.SA[i]] << ' '; cout << "ID\n";
    // for (int i = 0; i <= n; ++i) cout << sum[i] << ' '; cout << "SUM\n";
    // exit(0);
    auto Sum = [&](int l, int r) {
        //cerr << l << ' ' << r << '\n';
        return sum[r] - sum[l - 1];
    };
    int root = 0;
    int node = 0;
    int temp = 0;
    int it = 0;
    vector<pair<int, int> > Stack;
    Stack.push_back({0, 0});
    for (int i = 1; i <= n; ++i) {
        auto addStack = [&] (auto i, auto lcp) {
            //cerr << "add " << i << ' ' << lcp << ' ' << Stack.size() << '\n';
            while (Stack.size() > 1 && Stack.back().second >= lcp) {
                auto x = Stack.back();
                Stack.pop_back();
                if (x.second > lcp) {
                    ans = max(ans, 1ll * x.second * Sum(Stack.back().first + 1, i));
                }
            }
            Stack.push_back({i, lcp});
        };
        addStack(i, END[id[SA.SA[i]]] - SA.SA[i]);
        addStack(i, SA.LCP[i]);
    }
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 100;

struct SuffixArray {
    int n;
    string s;
    vector<int> SA, RA, tempSA, tempRA, LCP, L;

    SuffixArray() {}
    SuffixArray(string st) {
        s = st;
        RA.clear();
        n = s.size();
        RA.resize(n + 1, 0);
        SA = tempSA = tempRA = LCP = RA;
        L.resize(N);
        BuildSA();
    }

    void BuildSA() {
        for (int i = 0; i < n; ++i) SA[i] = i, RA[i] = s[i];
        for (int k = 1; k <= n; k <<= 1) {
            radix_sort(k); radix_sort(0);
            for (int i = 1, r = 0; i < n; ++i) {
                if (getRA(SA[i - 1]) != getRA(SA[i]) || getRA(SA[i - 1] + k) != getRA(SA[i] + k)) ++r;
                tempRA[SA[i]] = r;
            }
            for (int i = 0; i < n; ++i) RA[i] = tempRA[i];
            if (RA[SA[n - 1]] == n - 1) break;
        }
        //
        for (int i = 0; i < n; ++i) RA[SA[i]] = i;
        for (int i = 0, k = 0; i < n; ++i) {
            if (RA[i] == n - 1) { k = 0; continue; }
            int j = SA[RA[i] + 1];
            while (max(i, j) + k < n && s[i + k] == s[j + k] && s[i + k] != '$') ++k;
            LCP[RA[i]] = k;
            if (k) --k;
        }
    }
private:
    inline int getRA(int i) { return i < n ? RA[i] : 0; }
    void radix_sort(int k) {
        for (int i = 0; i < N; ++i) L[i] = 0;
        for (int i = 0; i < n; ++i) L[getRA(i + k)]++;
        for (int i = 0, p = 0; i < N; ++i) {
            int x = L[i]; L[i] = p, p += x;
        }
        for (int i = 0; i < n; ++i) {
            int& x = L[getRA(SA[i] + k)];
            tempSA[x++] = SA[i];
        }
        for (int i = 0; i < n; ++i) SA[i] = tempSA[i];
    }
};

int id[N], c[N], sz[N];
long long sum[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    long long ans = 0;
    string st;
    int n;
    cin >> n;
    int length = 0;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        sz[i + 1] = s.size();
        for (char c : s) {
            id[st.size()] = i + 1;
            st.push_back(c);
        }
        id[st.size()] = 0;
        st.push_back('$');
    }
    for (int i = 1; i <= n; ++i) {
        cin >> c[i];
        ans = max(ans, 1ll * c[i] * sz[i]);
    }
    //
    n = st.size() - 1;
    SuffixArray SA(st);
    // cout << st << '\n';
    // for (int i = 0; i <= n; ++i) cout << SA.SA[i] << ' '; cout << "SA\n";
    //for (int i = 0; i <= n; ++i) cout << SA.LCP[i] << ' '; cout << "LCP\n";
    //for (int i = 0; i <= n; ++i) cout << id[SA.SA[i]] << ' '; cout << "ID\n";
    for (int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1] + c[id[SA.SA[i]]];
    }
    //for (int i = 0; i <= n; ++i) cout << sum[i] << ' '; cout << "SUM\n";
    auto Sum = [&](int l, int r) { return sum[r] - sum[l - 1]; };
    vector<pair<int, long long> > hull(n + 1); // store <LCP, minSum>
    int sze = 1;
    hull[0] = {0, 0};
    for (int i = 2; i <= n; ++i) {
        // cout << i << ' ' << n << '\n';
        pair<int, long long> best = {SA.LCP[i - 1], sum[i - 2]};
        // cout << "Add " << best.first << ' ' << best.second << '\n';
        while (sze > 0 && sze  && (hull[sze - 1].first >= best.first ||hull[sze - 1].second >= best.second)) {
            best.second = min(best.second, hull[sze - 1].second);
            sze--;
        }
        auto a = [&] (pair<int, long long> x) { return x.first; };
        auto b = [&] (pair<int, long long> x) { return -x.second * x.first;};
        auto Eval = [&] (pair<int, long long> line, long long x) { return 1ll * a(line) * x + b(line); };
        // while (sze > 1 &&
        //     ((b(best) - b(hull[sze - 2])) * (a(hull[sze - 2]) - a(hull[sze - 1]))
        // <= (b(hull[sze - 1]) - b(hull[sze - 2]) * (a(hull[sze - 2]) - a(best))))) {
        //     --sze;
        // }
        hull[sze++] = best;
        // cout << "Hull now: \n";
        // for (int j = 0; j < sze; ++j) {
        //     cout << j << " = [" << a(hull[j]) << ',' << hull[j].second << "]\n";
        // }
        // (sumi - best.second) * best.first
        // sum * best.first - best.second * best.first
        auto Query = [&] (long long x) {
            // cout << "Query " << x << '\n';
            int lo = 0, hi = sze - 1, cur = 0;
            while (lo <= hi) {
                int mid = (lo + hi) >> 1;
                // a increasing
                // b decreasing
                // Find first
                if (x - hull[mid].second <= hull[mid].first) {
                    cur = mid;
                    lo = mid + 1;
                }
                //if (x * (a(hull[mid]) - a(hull[mid + 1]) < b(hull[mid + 1]) - b(hull[mid]))) lo = mid + 1;
                else hi = mid - 1;
            }
            // cout << "OPT " << lo << " = [" << a(hull[lo]) << ',' << b(hull[lo]) << "]\n";
            // cout << "Res = " << Eval(hull[lo], x) << ' ' << Eval(hull[cur + 1], x) << '\n';
            return max(Eval(hull[cur], x), (cur != sze - 1 ? Eval(hull[cur + 1], x) : 0));
        };
        ans = max(ans, Query(sum[i]));
    }
    cout << ans;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int n, a;
vector<int>vec;
vector<double>vec2;
double res = 0.00000;
const double PI = 3.1415926536;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		vec.push_back(a);
	}
	sort(vec.rbegin(), vec.rend());
	for (int i = 0; i < n; i++){
		res = vec[i] * vec[i] * PI;
		vec2.push_back(res);
	}
	reverse(vec2.begin(), vec2.end());
	res = 0.00000000;
	double res2 = 0.0;
	if (n % 2){
		if (n == 1){ res = vec[n - 1] * vec[n - 1] * PI; cout << setprecision(10) << fixed << res << endl; return 0; }
		for (int i = 2; i < n; i += 2){
			res = (vec2[i] - vec2[i - 1] + vec2[i - 2]);
			vec2[i] = res;
		}
	}
	else {
		if (n == 2){ res = vec2[1] - vec[0];	cout << setprecision(10) << fixed << res << endl; return 0; }
		res2 = vec2[n-1];
		res = 0.00000;
		for (int i = 2; i < n; i+=2){
			res = (vec2[i] - vec2[i - 1] + vec2[i - 2]);
			vec2[i] = res;
		}
		res2 -= res;
		res = res2;
	}
	cout << setprecision(10) << fixed << res << endl;
	return 0;
}


//Done el7amdulillah :D
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int n, a;
vector<int>vec;
vector<double>vec2;
double res = 0.00000;
const double PI = 3.1415926536;

int main(){

	int n;
	cin >> n;
	double res = 0.00;
	vector<int>vec;
	vec.push_back(0);
	for (int i = 0; i < n; i++){ int a; cin >> a; vec.push_back(a); }
	for (int i = n - 1; i>0; i-=2)res += PI*(vec[i] * vec[i] - vec[i - 1] * vec[i - 1]);
	cout << setprecision(5) << fixed << res << endl;
	/*cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		vec.push_back(a);
	}
	sort(vec.rbegin(), vec.rend());
	for (int i = 0; i < n; i++){
		res = vec[i] * vec[i] * PI;
		vec2.push_back(res);
	}
	reverse(vec2.begin(), vec2.end());
	res = 0.00000000;
	double res2 = 0.0;
	if (n % 2){
		if (n == 1){ res = vec[n - 1] * vec[n - 1] * PI; cout << setprecision(10) << fixed << res << endl; return 0; }
		for (int i = 2; i < n; i += 2){
			res = (vec2[i] - vec2[i - 1] + vec2[i - 2]);
			vec2[i] = res;
		}
	}
	else {
		if (n == 2){ res = vec2[1] - vec2[0];	cout << setprecision(10) << fixed << res << endl; return 0; }
		res2 = vec2[n - 1];
		res = 0.00000;
		for (int i = 2; i < n; i += 2){
			res = (vec2[i] - vec2[i - 1] + vec2[i - 2]);
			vec2[i] = res;
		}
		res2 -= res;
		res = res2;
	}
	cout << setprecision(10) << fixed << res << endl;*/
	return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int n, a;
vector<int>vec;
vector<double>vec2;
double res = 0.00000;
const double PI = 3.1415926536;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		vec.push_back(a);
	}
	sort(vec.rbegin(), vec.rend());
	for (int i = 0; i < n; i++){
		res = vec[i] * vec[i] * PI;
		vec2.push_back(res);
	}
	reverse(vec2.begin(), vec2.end());
	res = 0.00000000;
	double res2 = 0.0;
	if (n % 2){
		if (n == 1){ res = vec[n - 1] * vec[n - 1] * PI; cout << setprecision(10) << fixed << res << endl; return 0; }
		for (int i = 2; i < n; i += 2){
			res += (vec2[i] - vec2[i - 1] + vec2[i - 2]);
		}
	}
	else {
		if (n == 2){ res = vec2[1] - vec[0];	cout << setprecision(10) << fixed << res << endl; return 0; }
		res2 = vec2[n-1];
		res = 0.00000;
		for (int i = 2; i < n; i+=2){
			res += (vec2[i] - vec2[i - 1] + vec2[i - 2]);
		}
		res2 -= res;
		res = res2;
	}
	cout << setprecision(10) << fixed << res << endl;
	return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int n, a;
vector<int>vec;
vector<double>vec2;
double res = 0.00000;
const double PI = 3.1415926536;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		vec.push_back(a);
	}
	sort(vec.rbegin(), vec.rend());
	for (int i = 0; i < n; i++){
		res = vec[i] * vec[i] * PI;
		vec2.push_back(res);
	}
	reverse(vec2.begin(), vec2.end());
	res = 0.00000000;
	double res2 = 0.0;
	if (n % 2){
		if (n == 1){ res = vec[n - 1] * vec[n - 1] * PI; cout << setprecision(10) << fixed << res << endl; return 0; }
		for (int i = 2; i < n; i += 2){
			res = (vec2[i] - vec2[i - 1] + vec2[i - 2]);
			vec2[i] = res;
		}
	}
	else {
		if (n == 2){ res = vec2[1] - vec2[0];	cout << setprecision(10) << fixed << res << endl; return 0; }
		res2 = vec2[n-1];
		res = 0.00000;
		for (int i = 2; i < n; i+=2){
			res = (vec2[i] - vec2[i - 1] + vec2[i - 2]);
			vec2[i] = res;
		}
		res2 -= res;
		res = res2;
	}
	cout << setprecision(10) << fixed << res << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define f(k,n) for (int k=0;k<n;k++)
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define inf 1e9
#define i64 __int64
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define sqr(a) ((a)*(a))
#define eps 1e-4

const double pi = 3.14159265;
int main() {

    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, r;
    double total = 0, res = 0;
    cin>>n;
    vector<int> v;
    f(i,n) {
        cin >> r;
        v.pb(r);
    }
    sort(v.begin(),v.end());
    f(i,n) {
        if (i%2 == 0) res += (v[i]*v[i]*pi - total);
        total = v[i]*v[i]*pi;
    }
    cout << res;

}


#include <bits/stdc++.h>

using namespace std;
#define f(k,n) for (int k=0;k<n;k++)
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define inf 1e9
#define i64 __int64
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define sqr(a) ((a)*(a))
#define eps 1e-4

const double pi = 3.14159265;
int main() {

    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, r;
    double total = 0, res = 0;
    cin>>n;
    vector<int> v;
    f(i,n) {
        cin >> r;
        v.pb(r);
    }
    v.pb(0);
    sort(v.rbegin(),v.rend());
    f(i,n) {
        if (i%2 == 0) res += (v[i]*v[i] - v[i+1]*v[i+1])*pi;
    }
    printf("%0.10f",res);

}


#include <bits/stdc++.h>

using namespace std;
#define f(k,n) for (int k=0;k<n;k++)
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define inf 1e9
#define i64 __int64
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define sqr(a) ((a)*(a))
#define eps 1e-4

const double pi = 3.14159265;
int main() {

    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, r;
    double total = 0, res1 = 0, res2 = 0;
    cin>>n;
    vector<int> v;
    f(i,n) {
        cin >> r;
        v.pb(r);
    }
    sort(v.begin(),v.end());
    f(i,n) {
        if (i%2 == 0) res1 += (v[i]*v[i]*pi - total);
        else res2 += (v[i]*v[i]*pi - total);
        total = v[i]*v[i]*pi;
    }
    cout << max(res1,res2);

}


#include <bits/stdc++.h>

using namespace std;
#define f(k,n) for (int k=0;k<n;k++)
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define inf 1e9
#define i64 __int64
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define sqr(a) ((a)*(a))
#define eps 1e-4

const double pi = 3.14159265;
int main() {

    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, r;
    double total = 0, res = 0;
    cin>>n;
    vector<int> v;
    f(i,n) {
        cin >> r;
        v.pb(r);
    }
    sort(v.rbegin(),v.rend());
    f(i,n) {
        if (i%2 == 0) res += (v[i]*v[i] - v[i+1]*v[i+1])*pi;
    }
    printf("%0.10f",res);

}


#include <bits/stdc++.h>
using namespace std;

#define PI 3.1415926536
#define pb push_back

vector <int> circ;

int main(){

	int n;
	scanf("%d",&n);

	for(int i=0;i<n;i++){
		int aux; scanf("%d",&aux);
		circ.pb(aux);
	}
	sort(circ.rbegin(), circ.rend());

	double resp = 0;

	int sig = 1;

	for(int i=0;i<n;i++){
		resp+= sig*(circ[i]*circ[i]*PI);
		sig*=-1;
	}

	printf("%.9lf\n",resp);

	return 0;
}
// 1535851774659


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const double PI= 2*acos(0.0);
bool comp(const int a,const int b) {
	return a > b;
}

int main() {
	int sign = 1, n, radios[105];
	double area = 0;

	scanf("%d",&n);

	for(int i=0; i<n; i++) {
		scanf("%d",&radios[i]);
	}

	sort(radios, radios+n, comp);

	for(int i=0; i<n; i++) {
		area += double(sign*(PI*radios[i]*radios[i]));
		sign *= -1;
	}

	cout.precision(10);
	cout<<fixed;
	cout<<area<<endl;
	return 0;
}
// 1535746558982


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

#define PI acos(-1)

using namespace std;

int main(){
	int n;
	double ans;
	cin >> n;
	vector <int> r;
	while(n--){
		int aux;
		cin >> aux;
		r.push_back(aux);
	}
	sort(r.begin(), r.end());
	for(int i = r.size() - 1; i > 0; i -= 2){
		ans += PI*(r[i]*r[i] - r[i-1]*r[i-1]);
	}
	if(r.size() % 2){
		ans += PI*r[0]*r[0];
	}
	cout << ans;
	return 0;
}
// 1535744544838


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int sign = 1, n, radios[105];
	double area= 0;

	scanf("%d",&n);

	for(int i=0; i<n; i++) {
		scanf("%d",&radios[i]);
	}

	sort(radios, radios+n);

	for(int i= 0; i<n; i++) {
		area = double(area + sign*(M_PI*radios[i]*radios[i]));
		sign *= -1;
	}
    printf("%.10g",area);
	return 0;
}

// 1535745959791


#include <bits/stdc++.h>
#define PI 3.1415926536

using namespace std;

int main (){

	ios :: sync_with_stdio(false);

	int n,x;
	double sum = 0;

	vector<int> v;
	cin >> n;

	while(n--){
		cin >> x;
		v.push_back(x);
	}

	sort(v.rbegin(),v.rend());

	for (int i = 0; i < v.size(); i+=2){

		sum += pow(v[i],2);
	}
	for (int i = 1; i < v.size(); i+=2){
		sum -= pow(v[i],2);
	}

	cout << sum * PI << endl;

}
// 1536267963834


#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n, a[200];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	sort(a, a+n);
	int flag = 1, ans = 0;
	for(int i = 0; i < n; i++){
		ans += flag * a[i] * a[i];
		flag *= -1;
	}
	const double pi = 3.1415926535897932384626;
	printf("%.10lf\n", pi*ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n, a[200];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	sort(a, a+n);
	int flag = 1, ans = 0;
	for(int i = n-1; i >= 0; i--){
		ans += flag * a[i] * a[i];
		flag *= -1;
	}
	const double pi = 3.1415926535897932384626;
	printf("%.10lf\n", pi*ans);
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define rep(i, j, k) for (int i = j; i <= k; i++)
#define pi atan (1.0)*4

using namespace std;

int n, a[10009];
double ans = 0;

double calc (int x)
{
	double ret = x *1.0 * x;
	return ret * pi;
}

int main ()
{
	cin >> n;
	rep (i, 1, n)
		scanf ("%d", &a[i]);
	sort (a + 1, a + 1 + n);
	if (n % 2 == 0)
		n--;
	rep (i, 1, n)
		if (i % 2)
			ans += calc (a[i]);
		else
			ans -= calc (a[i]);
	printf ("%.6lf\n", ans);
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define rep(i, j, k) for (int i = j; i <= k; i++)
#define pi atan (1.0)*4

using namespace std;

int n, a[10009];
double ans = 0;

double calc (int x)
{
	double ret = x *1.0 * x;
	return ret * pi;
}

int main ()
{
	cin >> n;
	rep (i, 1, n)
		scanf ("%d", &a[i]);
	sort (a + 1, a + 1 + n);
	if (n % 2)
	{
		rep (i, 1, n)
			if (i % 2)
				ans += calc (a[i]);
			else
				ans -= calc (a[i]);
	}
	else
	{
		rep (i, 1, n)
			if (i % 2 == 0)
				ans += calc (a[i]);
			else
				ans -= calc (a[i]);
	}
	printf ("%.6lf\n", ans);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int sign = 1, n, radios[105];
	double area= 0;

	scanf("%d",&n);

	for(int i=0; i<n; i++) {
		scanf("%d",&radios[i]);
	}

	sort(radios, radios+n);

	for(int i= 0; i<n; i++) {
		area = double(area + sign*(M_PI*radios[i]*radios[i]));
		sign *= -1;
	}
	cout.precision(10);
	cout<<fixed;
	cout<<area<<endl;
	return 0;
}

// 1535745428539


#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846
#define fastcin ios_base::sync_with_stdio(false)
#define precisecout cout << fixed << setprecision(10)
#define pb push_back
#define mk make_pair
#define mkt make_tuple
#define get(x, i) get<i>(x)
#define mod109 1000000007
#define binary(x) bitset<8*sizeof(x)>(x)
#define zero(x) memset(x, 0, sizeof(x))
#define set(x, i) memset(x, i, sizeof(x))
#define ii pair<int, int>
#define inf 0x3f3f3f3f

int main(){
	int n;
	cin >> n;
	vector<int> circles;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		circles.pb(x);
	}

	sort(circles.rbegin(), circles.rend());

	bool red = true;

	double tot = 0;
	for(int x : circles){
		if(red)
			tot += PI * x * x;
		else
			tot -= PI * x * x;

		red = !red;
	}

	precisecout;
	cout << tot << endl;
}
// 1535744439898


#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main (){
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int n; // # circles
    cin >> n;

    vector<int> radius(n);
    int r;
    for (int i = 0; i < n; i++){
        cin >> r;
        radius[i] = r;
    }

    // for (int i = 0; i < n; i++){
    //     cout << radius[i] << " ";
    // }
    // cout << endl;

    // Sort the vector to put the concentric circles from the outermost to the
    // inermost one
    sort(radius.rbegin(), radius.rend());

    // We knot the outermost circle is painted red so we have a pattern
    double totalArea = 0;
    for (int c = 0; c < n; c += 2){
        if (c == n - 1){
            // cout << "last one: " << c << " with r = " << radius[c];
            totalArea += radius[c]*radius[c];
            continue;
        }

        totalArea += radius[c]*radius[c] - radius[c+1]*radius[c+1];
        // cout << "not last one" << endl;
    }
    totalArea *= M_PI;
    printf("%.5f\n", totalArea);

    return 0;
}

// 1535746635378


#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

// #define _USE_MATH_DEFINES
#define PI 3.141592

using namespace std;

int main (){
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int n; // # circles
    cin >> n;

    vector<int> radius(n);
    int r;
    for (int i = 0; i < n; i++){
        cin >> r;
        radius[i] = r;
    }

    // for (int i = 0; i < n; i++){
    //     cout << radius[i] << " ";
    // }
    // cout << endl;

    // Sort the vector to put the concentric circles from the outermost to the
    // inermost one
    sort(radius.rbegin(), radius.rend());

    // We knot the outermost circle is painted red so we have a pattern
    double totalArea = 0;
    for (int c = 0; c < n; c += 2){
        if (c == n - 1){
            // cout << "last one: " << c << " with r = " << radius[c];
            totalArea += radius[c]*radius[c];
            continue;
        }

        totalArea += radius[c]*radius[c] - radius[c+1]*radius[c+1];
        // cout << "not last one" << endl;
    }
    totalArea *= PI;
    printf("%.5f\n", totalArea);

    return 0;
}

// 1535747222909


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const double PI= 2*acos(0.0);
int main() {
	int sign = 1, n, radios[105];
	double area = 0;

	scanf("%d",&n);

	for(int i=0; i<n; i++) {
		scanf("%d",&radios[i]);
	}

	sort(radios, radios+n);

	for(int i=0; i<n; i++) {
		area += double(sign*(PI*radios[i]*radios[i]));
		sign *= -1;
	}

	cout.precision(10);
	cout<<fixed;
	cout<<area<<endl;
	return 0;
}
// 1535746380905


#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

const double pi = 3.14159;

int main(){

    int n, in; cin >> n;
    int arr[n];
    double r=0;

    for (int i=0; i<n; ++i){
        cin >> arr[i];
    }

    sort(arr, arr+n);
    reverse(arr, arr+n);

    for (int i=0; i<n; ++i){
        in = arr[i];
        if (i%2==0){
            r += pi*in*in;
        } else {
            r -= pi*in*in;
        }
    }

    cout << r;

    return 0;
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi = 3.14159;

double func(double fl, double on){
    return pi*pow(fl,2)- pi*pow(on,2);
}

int main(){

    int n, one, follow, countt=2; cin >> n;
    double res;

    cin >> one;
    res=pi*pow(one,2);

    if (n==1){
        cout << res;
        return 0;
    }

    int arr[n];
    arr[0]=one;
    for (int i=1; i<n; ++i){
        cin >> arr[i];
    }

    sort (arr, arr+n);

    for (int i=1; i<n; ++i){
        follow=arr[i];
        if (countt%2!=0){
            res+=func(follow, one);
        }
        one=follow;
        ++countt;
    }

    cout << res;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const double pi = 3.14159;

int main(){

    int n, in; cin >> n;
    int arr[n];
    double r=0;

    for (int i=0; i<n; ++i){
        cin >> arr[i];
    }

    sort(arr, arr+n, greater<>());

    for (int i=0; i<n; ++i){
        in = arr[i];
        if (i%2==0){
            r += pi*in*in;
        } else {
            r -= pi*in*in;
        }
    }

    cout << r;

    return 0;
}


#include <bits/stdc++.h>
#include <string>

using namespace std;

const double pi = 3.14159;

int main(){

    int n, in; cin >> n;
    int arr[n];
    double r=0;

    for (int i=0; i<n; ++i){
        cin >> arr[i];
    }

    sort(arr, arr+n);

    for (int i=0; i<n; ++i){
        in = arr[i];
        if (i%2==0){
            r += pi*in*in;
        } else {
            r -= pi*in*in;
        }
    }

    cout << r;

    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
const double PI=3.1415926535898;
int r[10005];
int main(){
	int n;
	double ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&r[i]);
	sort(r+1,r+1+n);
	if(n%2==0) n--;
	for(int i=1;i<=n;i++)
	{
		if(i%2==1) ans+=r[i]*r[i];
		else ans-=r[i]*r[i];
	}
	printf("%.10lf",ans*PI);
	return 0;
}


#include<bits/stdc++.h>
#define pi 3.14159265358979323846
using namespace std;
int n;
double r[105];
double ans;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>r[i];
	}sort(r+1,r+1+n);
	if(n%2==0) n--;
	for(int i=1;i<=n;i++)
	{
		if(i&1) ans+=(r[i]*r[i])*pi;
		else ans-=(r[i]*r[i])*pi;
	}
//	cout<<ans<<endl;
	printf("%0.10f\n",ans);
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
const double PI=3.1415926535898;
int r[10005];
int main(){
	int n;
	double ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&r[i]);
	sort(r+1,r+1+n);
	//if(n%2==0) n--;
	for(int i=n;i>=1;i-=2) ans+=r[i]*r[i]-r[i-1]*r[i-1];
	printf("%.10lf\n",double(ans*PI));
	return 0;
}


#include <bits/stdc++.h>
int t, a[105], val;
int main(void) {
    double PI = acos(-1);
    std::cin>>t;
    for (int i = 0; i < t; ++i) scanf("%d", a+i);
    std::sort(a, a + t);
    for (int i = t - 1; i >= 0; i -= 2)
        val = val + (i - 1 >= 0 ? ((a[i] * a[i]) - (a[i - 1] * a[i - 1])) : a[i] * a[i]);
    printf("%.10lf\r", (double)PI * val);
}


#include<bits/stdc++.h>
#define PI 3.1415926536
using namespace std;
int main(){

int X;
cin >> X;

int *Y = new int[X];

for(int i=0;i<X;i++)
cin >> Y[i];

sort(Y,Y+X);

double ans = Y[0]*Y[0]*PI;

for(int i=1;i<X-1;i++)
ans+=((Y[i+1]*PI*Y[i+1]-Y[i]*PI*Y[i]));

cout<<ans;

}


#include<bits/stdc++.h>
#define PI 3.1415926536
using namespace std;
int main(){

int X,F=0;
cin >> X;

int *Y = new int[X];

for(int i=0;i<X;i++)
cin >> Y[i];

sort(Y,Y+X);
reverse(Y,Y+X);
double ans = 0;

for(int i=0;i<X;i+=2)
ans+=(abs(Y[i]*PI*Y[i]-Y[i+1]*PI*Y[i+1]));

cout<<ans;

}


#include<bits/stdc++.h>
#define PI 3.1415926536
using namespace std;
int main(){

int X,F=0;
cin >> X;

int *Y = new int[X];

for(int i=0;i<X;i++)
cin >> Y[i];

double ans = Y[0]*Y[0]*PI;

for(int i=1;i<X;i++)
if(F==1){
ans+=(abs(Y[i]*PI*Y[i]-Y[i-1]*PI*Y[i-1]));
F=0;
} else F=1;
cout<<ans;

}


#include<bits/stdc++.h>
#define PI 3.1415926536

int Y[100];

using namespace std;
int main(){

int X,F=0;
cin >> X;

for(int i=0;i<X;i++)
cin >> Y[i];

sort(Y,Y+X);
reverse(Y,Y+X);
double ans = 0;

for(int i=0;i<X;i+=2)
ans+=(abs(Y[i]*PI*Y[i]-Y[i+1]*PI*Y[i+1]));

printf("%.10lf",ans);

}


#include<bits/stdc++.h>
#define PI 3.1415926536
using namespace std;
int main(){

int X,F=0;
cin >> X;

int *Y = new int[X];

for(int i=0;i<X;i++)
cin >> Y[i];

sort(Y,Y+X);
reverse(Y,Y+X);
double ans = 0;

for(int i=0;i<X;i+=2)
ans+=(abs(Y[i]*PI*Y[i]-Y[i+1]*PI*Y[i+1]));

printf("%.10lf",ans);

}


#include<bits/stdc++.h>
#define PI 3.1415926536
using namespace std;
int main(){

int X,F=0;
cin >> X;

int *Y = new int[X+3];

for(int i=0;i<X;i++)
cin >> Y[i];

sort(Y,Y+X);
reverse(Y,Y+X);
double ans = 0;

for(int i=0;i<X;i+=2)
ans+=(abs(Y[i]*PI*Y[i]-Y[i+1]*PI*Y[i+1]));

printf("%.10lf",ans);

}


#include<bits/stdc++.h>
using namespace std;
int main(){

int X,F=0;
cin >> X;

int *Y = new int[X];

for(int i=0;i<X;i++)
cin >> Y[i];

sort(Y,Y+X);
reverse(Y,Y+X);
double ans = 0;

for(int i=0;i<X;i+=2)
ans+=(abs(Y[i]*M_PI*Y[i]-Y[i+1]*M_PI*Y[i+1]));

cout<<ans;

}


#include <bits/stdc++.h>
using namespace std;
#define ll double
int main()
{

     ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
 cout<<setprecision(10)<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint);
    double  pi=22/7.0;
    double sum=0,f=1.0;
    ll n,x;
    vector<ll>v;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
    cin>>x;
    v.push_back(x);
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<v.size();i++)
    {
        sum+=v[i]*v[i]*pi*f;
        f*=-1;
    }
cout <<sum;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll double
int main()
{

     ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
 cout<<setprecision(10)<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint);
    double  pi=22/7.0;
    double sum=0;
    ll n,x;
    vector<ll>v;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
    cin>>x;
    v.push_back(pow(x,2));
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<v.size();i++)
    {
        sum+=v[i]*pi*pow(-1,i);
    }
cout <<sum;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll double
int main()
{

     ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
 cout<<setprecision(10)<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint);
    double  pi=3.1428571429;
    double sum=0;
    ll n,x;
    vector<ll>v;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
    cin>>x;
    v.push_back(pow(x,2));
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<v.size();i++)
    {
        sum+=v[i]*pi*pow(-1,i);
    }
cout <<sum;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll double
int main()
{

     ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
 //cout<<setprecision(10)<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint);
    double  pi=3.141592653589793;
    double sum=0,f=1.0;
    ll n,x;
    vector<ll>v;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
    cin>>x;
    v.push_back(x);
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<v.size();i++)
    {
        sum+=v[i]*v[i]*pi*f;
        f*=-1;
    }
cout <<sum;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll double
int main()
{

     ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
 cout<<setprecision(10)<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint);
    double  pi=3.1428571429;
    double sum=0;
    ll n,x;
    vector<ll>v;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
    cin>>x;
    v.push_back(x);
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<v.size();i++)
    {
        sum+=v[i]*v[i]*pi*pow(-1,i);
    }
cout <<sum;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll double
int main()
{

     ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
 cout<<setprecision(10)<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint);
    double  pi=3.1428571429;
    double sum=0,f=1.0;
    ll n,x;
    vector<ll>v;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
    cin>>x;
    v.push_back(x);
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<v.size();i++)
    {
        sum+=v[i]*v[i]*pi*f;
        f*=-1;
    }
cout <<sum;
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<numeric>
#include<cmath>
#include<utility>
#include<set>
#include <iterator>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 9223372036854775807
#define INF 2000000000
#define PI acos(-1)
#define EPS 1e-9
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))

using namespace std;

int main()
{
	LL sum = 0;
	int n, blue, red;
	cin >> n;
	vector <int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.rbegin(), a.rend());
	for(int i = 0; i < n; i += 2) sum += a[i] * a[i] - a[i + 1] * a[i + 1];
	cout << (double) sum *  PI;
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<numeric>
#include<cmath>
#include<utility>
#include<set>
#include <iterator>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 9223372036854775807
#define INF 2000000000
#define PI 3.1415926536
#define EPS 1e-9
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))

using namespace std;

int main()
{
	LL sum = 0;
	int n, blue, red;
	cin >> n;
	vector <int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.rbegin(), a.rend());
	for(int i = 0; i < n; i += 2) sum += a[i] * a[i] - a[i + 1] * a[i + 1];
	cout << (double) sum *  PI;
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<numeric>
#include<cmath>
#include<utility>
#include<set>
#include <iterator>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 9223372036854775807
#define INF 2000000000
#define PI 3.1415926536
#define EPS 1e-9
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))

using namespace std;

int main()
{
	LL sum = 0;
	double pi = 3.1415926536;
	int n, blue, red;
	cin >> n;
	vector <int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	for(int i = 0; i < n; i += 2) sum += a[i] * a[i] - a[i + 1] * a[i + 1];
	cout << (double) sum *  pi;
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<numeric>
#include<cmath>
#include<utility>
#include<set>
#include <iterator>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 9223372036854775807
#define INF 2000000000
#define PI 3.1415926536
#define EPS 1e-9
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))

using namespace std;

int main()
{
	LL sum = 0;
	double pi = 3.1415926536;
	int n, blue, red;
	cin >> n;
	vector <int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.rbegin(), a.rend());
	for(int i = 0; i < n; i += 2) sum += a[i] * a[i] - a[i + 1] * a[i + 1];
	cout << (double) sum *  pi;
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<numeric>
#include<cmath>
#include<utility>
#include<set>
#include <iterator>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 9223372036854775807
#define INF 2000000000
#define PI 3.1415926536
#define EPS 1e-9
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))

using namespace std;

int main()
{
	double sum = 0;
	double pi = 3.1415926536;
	int n, blue, red;
	cin >> n;
	vector <int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.rbegin(), a.rend());
	for(int i = 0; i < n; i += 2) sum += a[i] * a[i] - a[i + 1] * a[i + 1];
	cout << (double) sum *  pi;
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<numeric>
#include<cmath>
#include<utility>
#include<set>
#include <iterator>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 9223372036854775807
#define INF 2000000000
#define PI 3.1415926536
#define EPS 1e-9
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))

using namespace std;

int n, r[105], s = 0;
double pi=3.1415926536;
int main()
{
	cin>>n;
	for(int i = 0; i < n; i++) cin>>r[i];
	sort(r,r+n);
	reverse(r,r+n);
	for(int i = 0; i < n; i += 2) s += r[i] * r[i] - r[i+1] * r[i+1];
	cout << s * pi;
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<numeric>
#include<cmath>
#include<utility>
#include<set>
#include <iterator>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 9223372036854775807
#define INF 2000000000
#define PI acos(-1)
#define EPS 1e-9
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))

using namespace std;

int main()
{
	LL sum = 0;
	int n, blue, red;
	cin >> n;
	vector <int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.rbegin(), a.rend());
	for(int i = 0; i < n; i += 2) sum += a[i] * a[i] - a[i + 1] * a[i + 1];
	cout << sum *  PI;
	return 0;
}


#include <iomanip>
#include<stdio.h>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
   int n;
   double pi=3.14159265,ans=0;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
       cin>>a[i];
   sort(a,a+n);
   reverse(a,a+n);
   //for(int i=0;i<n;i++)
       //cout<<a[i];
   if(n%2!=0)
   {
      for(int i=0;i<n;i++)
      {
          if(i+1<n && i+1!=n-1)
          ans+=((pi*a[i]*a[i])-(pi*a[i+1]*a[i+1]));
          if(i+1==n-1)
            {ans+=(pi*a[i+1]*a[i+1]); break;}
      }
   }
   else
   {
       for(int i=1;i<n;i++)
      {
          if(i+1<n && i+1!=n-1)
          ans+=((pi*a[i]*a[i])-(pi*a[i+1]*a[i+1]));
          if(i+1==n-1)
            {ans+=(pi*a[i+1]*a[i+1]); break;}

      }
   }
   cout<<setprecision(16)<<ans;
    return 0;
}


#include<stdio.h>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
   int n;
   double pi=3.14159265,ans=0;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
       cin>>a[i];
   sort(a,a+n);
   reverse(a,a+n);
   if(n%2!=0)
   {
       if(n==1)
       {ans+=(pi*a[0]*a[0]); cout<<ans; return 0; }
      for(int i=0;i<n;i++)
      {
          if(i+1<n && i+1!=n-1)
          ans+=((pi*a[i]*a[i])-(pi*a[i+1]*a[i+1]));
          if(i+1==n-1)
            {ans+=(pi*a[i+1]*a[i+1]); break;}
      }
   }
   else
   {
       for(int i=1;i<n;i++)
      {
          if(i+1<n && i+1!=n-1)
          ans+=((pi*a[i]*a[i])-(pi*a[i+1]*a[i+1]));
          if(i+1==n-1)
            {ans+=(pi*a[i+1]*a[i+1]); break;}

      }
   }
   cout<<ans;
    return 0;
}


#include<stdio.h>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
   int n;
   double pi=3.14159265,ans=0;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
       cin>>a[i];
   sort(a,a+n);
   reverse(a,a+n);
   if(n%2!=0)
   {
       if(n==1)
       {ans+=(pi*a[0]*a[0]); cout<<ans; return 0; }
      for(int i=0;i<n;i++)
      {
          if(i+1<n && i+1!=n-1)
          ans+=((pi*a[i]*a[i])-(pi*a[i+1]*a[i+1]));
          if(i+1==n-1)
            {ans+=(pi*a[i+1]*a[i+1]); break;}
      }
   }
   cout<<ans;
    return 0;
}


#include <iomanip>
#include<stdio.h>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
   int n;
   double pi=3.14159265,ans=0;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
       cin>>a[i];
   sort(a,a+n);
   reverse(a,a+n);
   //for(int i=0;i<n;i++)
       //cout<<a[i];
   if(n%2!=0)
   {
      for(int i=0;i<n;i++)
      {
          if(i+1<n && i+1!=n-1)
          ans+=((pi*a[i]*a[i])-(pi*a[i+1]*a[i+1]));
          if(i+1==n-1)
            {ans+=(pi*a[i+1]*a[i+1]); break;}
      }
   }
   else
   {
       for(int i=1;i<n;i++)
      {
          if(i+1<n && i+1!=n-1)
          ans+=((pi*a[i]*a[i])-(pi*a[i+1]*a[i+1]));
          if(i+1==n-1)
            {ans+=(pi*a[i+1]*a[i+1]); break;}

      }
   }
   cout<<ans;
    return 0;
}


#include<stdio.h>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
   int n;
   double pi=3.14159265,ans=0;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
       cin>>a[i];
   sort(a,a+n);

      for(int i=n-1;i>=0;i-=2)
      {
          if(i)
             ans+=((pi*a[i]*a[i])-(pi*a[i-1]*a[i-1]));
          else
            {ans+=(pi*a[i]*a[i]);}
      }
   cout<<ans;
    return 0;
}


#include<stdio.h>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
   int n;
   double pi=3.14159265,ans=0;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
       cin>>a[i];
   sort(a,a+n);
   reverse(a,a+n);

       if(n==1)
       {ans+=(pi*a[0]*a[0]); cout<<ans; return 0; }
      for(int i=0;i<n;i++)
      {
          if(i+1<n && i+1!=n-1)
          ans+=((pi*a[i]*a[i])-(pi*a[i+1]*a[i+1]));
          if(i+1==n-1)
            {ans+=(pi*a[i+1]*a[i+1]); break;}
      }
   cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n,c[105];

double pi = 3.14159265358979323846;

int main () {

    cin >> n;

    for (int i=0; i<n; i++) {
        cin >> c[i];
    }

    sort (c, c+n);

    bool red;
    if (n%2 == 1) red = true;
    else red = false;

    double total = 0.0f;

    if (red) {
        total += (double)c[0]* (double)c[0] * pi;
    } red = !red;

    for (int i=1; i<n; i++) {
        if (red) {
            total += (double)c[i] * (double)c[i] * pi;
            total -= (double)c[i-1] * (double)c[i-1] * pi;
        }
        red = !red;
    }

    printf("%.8f", total);
}


#include <bits/stdc++.h>
using namespace std;

int n,c[105];

double pi = 3.14159265358979323846;

int main () {

    cin >> n;

    for (int i=0; i<n; i++) {
        cin >> c[i];
    }

    sort (c, c+n);

    bool red;
    if (n%2 == 1) red = true;
    else red = false;

    double total = 0.0f;

    if (red) {
        total += (double)c[0]*pi;
    } red = !red;

    for (int i=1; i<n; i++) {
        if (red) {
            total += (double)c[i] * (double)c[i] * pi;
            total -= (double)c[i-1] * (double)c[i-1] * pi;
        }
        red = !red;
    }

    printf("%.8f", total);
}


#include <bits/stdc++.h>
#include <cmath>
using namespace std;

#define _USE_MATH_DEFINES

int n,c[105];

int main () {

    cin >> n;

    for (int i=0; i<n; i++) {
        cin >> c[i];
    }

    sort (c, c+n);

    bool red;
    if (n%2 == 1) red = true;
    else red = false;

    double total = 0.0f;

    if (red) {
        total += (double)c[0]*M_PI;
    } red = !red;

    for (int i=1; i<n; i++) {
        if (red) {
            total += (double)c[i] * (double)c[i] * M_PI;
            total -= (double)c[i-1] * (double)c[i-1] * M_PI;
        }
        red = !red;
    }

    printf("%.8f", total);
}


#include <bits/stdc++.h>
using namespace std;

int n,c[105];

int main () {

    cin >> n;

    for (int i=0; i<n; i++) {
        cin >> c[i];
    }

    sort (c, c+n);

    bool red;
    if (n%2 == 1) red = true;
    else red = false;

    double total = 0.0f;

    if (red) {
        total += (double)c[0]*M_PI;
    } red = !red;

    for (int i=1; i<n; i++) {
        if (red) {
            total += (double)c[i] * (double)c[i] * M_PI;
            total -= (double)c[i-1] * (double)c[i-1] * M_PI;
        }
        red = !red;
    }

    printf("%.8f", total);
}


#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;

int n,c[105];

int main () {

    cin >> n;

    for (int i=0; i<n; i++) {
        cin >> c[i];
    }

    sort (c, c+n);

    bool red;
    if (n%2 == 1) red = true;
    else red = false;

    double total = 0.0f;

    if (red) {
        total += (double)c[0]*M_PI;
    } red = !red;

    for (int i=1; i<n; i++) {
        if (red) {
            total += (double)c[i] * (double)c[i] * M_PI;
            total -= (double)c[i-1] * (double)c[i-1] * M_PI;
        }
        red = !red;
    }

    printf("%.8f", total);
}


#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main()
{
int n;

    double pi = 3.14159265358979323846 ;
    cin >>n;
    int a[n];
    for (int i =0 ; i < n ; i ++)cin>>a[i];
    int sw ;
    for (int i =0 ; i < n ; i++)for(int j =i ; j < n ; j++){
        if(a[i]>a[j]){
            sw =a[j];
            a[j]=a[i];
            a[i]=sw;
            }}
    double sum =0;
        for (int i = n-1 ; i >= 0 ; i -= 2){
        if ( i ==0 ){sum +=(pi*(a[i]*a[i]));}
        else {sum+=(pi*(pow(a[i],2)- pow(a[i-1],2)));}
        }
    cout<<sum;
    return 0;}


#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main()
{
int n;
    int a[n];
    double pi = 3.14159265358979323846 ;
    cin >>n;
    for (int i =0 ; i < n ; i ++)std::cin>>a[i];
    int sw ;
    for (int i =0 ; i < n ; i++)for(int j =i ; j < n ; j++){
        if(a[i]>a[j]){
            sw =a[j];
            a[j]=a[i];
            a[i]=sw;
            }}
    double sum =0;
        for (int i = n-1 ; i >= 0 ; i -= 2){
        if ( i ==0 ){sum +=(pi*(a[i]*a[i]));}
        else {sum+=(pi*(pow(a[i],2)-pow(a[i-1],2)));}
        }
    std::cout<<sum;
    return 0;}


#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main()
{
int n;
    int a[n];
    double pi = 3.14159265358979323846 ;
    cin >>n;
    for (int i =0 ; i < n ; i ++)cin>>a[i];
    int sw ;
    for (int i =0 ; i < n ; i++)for(int j =i ; j < n ; j++){
        if(a[i]>a[j]){
            sw =a[j];
            a[j]=a[i];
            a[i]=sw;
            }}
    double sum =0;
        for (int i = n-1 ; i >= 0 ; i -= 2){
        if ( i ==0 ){sum +=(pi*(a[i]*a[i]));}
        else {sum+=(pi*(pow(a[i],2)- pow(a[i-1],2)));}
        }
    cout<<sum;
    return 0;}


#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main()
{
int n;

    double pi = 3.14159265358979323846 ;
    cin >>n;
    vector <int> a(n);
    for (int i =0 ; i < n ; i ++)cin>>a[i];
    int sw ;
    for (int i =0 ; i < n ; i++)for(int j =i ; j < n ; j++){
        if(a[i]>a[j]){
            sw =a[j];
            a[j]=a[i];
            a[i]=sw;
            }}
    double sum =0;
        for (int i = n-1 ; i >= 0 ; i -= 2){
        if ( i ==0 ){sum +=(pi*(a[i]*a[i]));}
        else {sum+=(pi*(pow(a[i],2)- pow(a[i-1],2)));}
        }
    cout<<sum;
    return 0;}


#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID (l+r)/2
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;
#define M_PI 3.1415926

int main(){
	int n;
	cin>>n;
	cout<<setprecision(10)<<fixed;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a, a+n);
	long double ans=0;
	for(int i=n-1;i>0;i-=2){
		ans+= M_PI * (a[i]*a[i] - a[i-1]*a[i-1]);
	}
	if(n%2)
		ans+=M_PI * a[0]*a[0];
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID (l+r)/2
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;
#define M_PI 3.1415926

int main(){
	int n;
	cin>>n;
	cout<<setprecision(10)<<fixed;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a, a+n);
	long double ans=0;
	for(int i=n-1;i>0;i-=2){
		ans+= M_PI * (a[i]*a[i] - a[i-1]*a[i-1]);
	}
	ans+=M_PI * a[0]*a[0];
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID (l+r)/2
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;

int main(){
	int n;
	cin>>n;
	cout<<setprecision(10)<<fixed;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a, a+n);
	long double ans=0;
	for(int i=n-1;i>0;i-=2){
		ans+= M_PI * (a[i]*a[i] - a[i-1]*a[i-1]);
	}
	ans+=M_PI * a[0]*a[0];
	cout<<ans<<endl;
}


#include <string>
#include <vector>
#include <iostream>
//#include<bits/stdc++.h>
using namespace std;

int main()
{
 int n ;     cin >> n; // num of photos
vector<int> v;
for(int i=0; i<n; i++) { int x ;  cin>> x; v.push_back(x); }

bool f=true;
sort(v.begin(), v.end());
long sum= v.end() * v.end() ;

for(int i=v.size()-2; i>=0; i--)
{
	//if (v[i]!=v[i+1])
	{
		if (f) sum -= v[i]*v[i];
		else sum += v[i]*v[i] ;
		f = !f;
	}
}

double res = 3.1415926*sum;
cout << res;
return 0;

}


#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
//#include<bits/stdc++.h>
using namespace std;

int main()
{
 int n ;     cin >> n; // num of photos
vector<int> v;
for(int i=0; i<n; i++) { int x ;  cin>> x; v.push_back(x); }

bool f=true;
sort(v.begin(), v.end());
long sum= v.end() * v.end() ;

for(int i=v.size()-2; i>=0; i--)
{
	//if (v[i]!=v[i+1])
	{
		if (f) sum -= v[i]*v[i];
		else sum += v[i]*v[i] ;
		f = !f;
	}
}

double res = 3.1415926*sum;
cout << res;
return 0;

}


#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
//#include<bits/stdc++.h>
using namespace std;

int main()
{
 int n ;     cin >> n; // num of photos
vector<int> v;
for(int i=0; i<n; i++) { int x ;  cin>> x; v.push_back(x); }

bool f=true;
sort(v.begin(), v.end());
long sum= v.back() * v.back() ;

for(int i=v.size()-2; i>=0; i--)
{
	//if (v[i]!=v[i+1])
	{
		if (f) sum -= v[i]*v[i];
		else sum += v[i]*v[i] ;
		f = !f;
	}
}

double res = 3.1415926*sum;
cout << res;
return 0;

}


#include <string>
#include <vector>
#include <iostream>
//#include<bits/stdc++.h>
using namespace std;

int main()
{
 int n ;     cin >> n; // num of photos
vector<int> v;
for(int i=0; i<n; i++) { int x ;  cin>> x; v.push_back(x); }

bool f=true;
long sum= v.end() * v.end() ;
sort(v.begin(), v.end());
for(int i=v.size()-2; i>=0; i--)
{
	if (v[i]!=v[i+1])
	{
		if (f) sum -= v[i]*v[i];
		else sum += v[i]*v[i] ;
		f = !f;
	}
}

cout << 3.1415926 * sum;
return 0;

}