// -*- C++ -*-
// File: a.cpp
// Copyright (C) 2013
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <memory.h>
#include <cstdio>
#include <assert.h>

using namespace std;

#define pb push_back
#define INF 1011111111
#define FOR(i,a,b) for (int _n(b), i(a); i < _n; i++)
#define rep(i,n) FOR(i,0,n)
#define CL(a,v) memset((a),(v),sizeof(a))
#define mp make_pair
#define X first
#define Y second
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;

/*** TEMPLATE CODE ENDS HERE */

string str;
int a[100100];
int dp[100100][2];
int n;

int f(int i, bool was) {
	if(i==n) return 0;
	if(dp[i][was]!=-1) return dp[i][was];

	int ans = f(i+1, was) + (str[i]=='1'||was?a[i]:0);

	if(str[i]=='1') {
		ans = max( f(i+1,was||true), ans );
	}

	return dp[i][was] = ans;}

int main() {
#ifdef LOCAL_HOST
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif

    ios_base::sync_with_stdio(false);

	cin >> n;
	rep(i,n) cin >> a[i];
	cin >> str;
	reverse(all(str));
	reverse(a,a+n);

	CL(dp,-1);
	cout << f(0,0) << endl;

#ifdef LOCAL_HOST
    printf("TIME: %.3lf\n",double(clock())/CLOCKS_PER_SEC);
#endif

    return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<ctime>
#include<climits>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<algorithm>
#include<complex>
#include<set>
#include<bitset>
#include<utility>
#include<valarray>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;

#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define all(a) (a).begin(),(a).end()
#define len(a) ((int)(a).size())
#define mem(a,n) memset(a,n,sizeof(a))
#define eps 1e-9
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,n) for(int i=(a);i<(n);i++)
#define repr(i,a,n) for(int i=(n);i>=(a);i--)

string s;
vll v;
ll ary[100005][2];
int n;

ll dp(int pos,int t){
	if(pos>=n)return 0;

	ll &ret = ary[pos][t];
	if(ret!=-1)return ret;
	ret = 0;
	if(t){
		ret = v[pos] + dp(pos+1,t);
	}else{
		if(s[pos]=='0'){
			ret = dp(pos+1,t);
		}else{
			ret = max(dp(pos+1,1),dp(pos+1,0)+v[pos]);
		}
	}
	return ret;
}

int main(void){
	ios_base::sync_with_stdio(0);
	cin>>n;
	v.resize(n);
	rep(i,n)cin>>v[i];
	cin>>s;
	reverse(all(s));
	reverse(all(v));
	mem(ary,-1);
	cout<<dp(0,0)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <list>
#include <set>
#include <map>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define clr(x, v) memset(x, v, sizeof(x))
#define rep(i, l, u) for(int i = (l); i < (u); i++)
#define repv(i, v) for(i = 0; i < (int)v.size(); i++)
#define repi(it, c) for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)

const int N = 100011;

int a[N], s[N], n, d[N];

int main () {
	int n, i, j, k;
	scanf ("%d", &n);
	for (i = 1; i <= n; ++i) {
		scanf ("%d", &a[i]);
		s[i] = s[i - 1] + a[i];
	}
	int last = 0;
	for (i = 1; i <= n; ++i) {
		scanf ("%1d", &k);
		if (k == 0) continue;
		d[k] = max (s[i-1], a[i] + d[last]);
		last = k;
	}
	printf ("%d\n", d[last]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100004],sol;
int sum[100004];
char s[100004];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    int ss = 0, n;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
        sum[i] = sum[i-1] + a[i];
    }
    cin >> s;
    for(int i=0;i<n;++i)
        if(s[i]=='1')
            sol += a[i];
    for(int i=n-1;i > 0;--i)
        if(s[i]=='1')
        {
            sol = max(sol,ss+sum[i-1]);
            ss += a[i];
        }
    cout<<sol<<"\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int INF = 1000 * 1000 * 1000;
const int N = 100 * 1000 + 10;

int dpSmall[N];
int dpEq[N];
string s;
int a[N];
int n;

int main()
{
    ios_base::sync_with_stdio(0);
    #if defined DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    cin >> s;
    fill(dpSmall, dpSmall + n + 1, -INF);
    fill(dpEq, dpEq + n + 1, -INF);
    dpEq[n] = 0;
    for (int i = n - 1; i >= 0; --i)
        for (int bit = 0; bit < 2; bit++)
        {
            int sbit = s[i] - '0';
            if (sbit == bit)
            {
                dpEq[i] = max(dpEq[i], dpEq[i + 1] + bit * a[i]);
                dpSmall[i] = max(dpSmall[i], dpSmall[i + 1] + bit * a[i]);
            }
            if (sbit > bit)
                dpSmall[i] = max(dpSmall[i], max(dpEq[i + 1], dpSmall[i + 1]) + bit * a[i]);
            if (sbit < bit)
                dpSmall[i] = max(dpSmall[i], dpSmall[i + 1] + bit * a[i]);
        }
    cout << max(dpSmall[0], dpEq[0]);

    return 0;
}


#include<iostream>
#include<cstring>
using namespace std;

long long int Max(long long int a,long long int b)
{
    if(a>b)
    return a;
    else
    return b;
}

class Test
{
    int N;
    int *Arr;
    char *Str;
    int **Store;
    public:
        Test()
        {
            cin>>N;
            Arr=new int[N+1];
            Str=new char[N+1];
            Store=new int*[N+1];

            for(int i=0;i<N;i++)
            {
                cin>>Arr[i];
            }
            for(int i=0;i<N;i++)
            {
                Store[i]=new int[2];
                Store[i][0]=-1;
                Store[i][1]=-1;
            }

            cin>>Str;
        }
        long long int Fun(int Pos,int Flag)
        {
            long long int Ans;

            if(Pos<0)return 0;

            if(Store[Pos][Flag]>-1)
            {
                //printf("From Store  Store[%d][%d]\n",Pos,Flag);
                return Store[Pos][Flag];
            }

            else
            {
                if(Flag==0)
                {
                    Ans=Max((Arr[Pos]+Fun(Pos-1,0)),Fun(Pos-1,0));
                    Store[Pos][0]=Ans;
                    return Ans;
                }
                else
                {
                    if(Str[Pos]=='0')
                    {
                        Ans=Fun(Pos-1,1);
                        Store[Pos][1]=Ans;
                        return Ans;
                    }
                    else
                    {
                        Ans=Max((Arr[Pos]+Fun(Pos-1,1)),Fun(Pos-1,0));
                        Store[Pos][1]=Ans;
                        return Ans;
                    }
                }
            }
        }
        void Result()
        {
            cout<<Fun(N-1,1)<<endl;
        }

};

main()
{
    Test *t;
    t=new Test;
    t->Result();
    delete t;
}


#include <bits/stdc++.h>
using namespace std;
#define TR(i,v) for(__typeof((v).begin())i=(v).begin();i!=(v).end();++i)
#define DEBUG(x) cout << #x << " = "; cout << x << endl;
#define SIZE(p) (int)(p).size()
#define MP(a, b)	make_pair((a), (b))
#define ALL(p)		(p).begin(), (p).end()
#define rep(i, n)	for(int (i)=0; (i)<(int)(n); ++(i))
#define FOR(i, a, b)   for(int (i)=(int)(a); (i)<=(int)(b); ++(i))
#define FORD(i, b, a)  for(int (i)=(int)(b); (i)>=(int)(a); --(i))
typedef long long LL;
typedef pair<int, int> pii;
int a[100005];
int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
    freopen("C.in", "r", stdin);
    // freopen("out", "w", stdout);
    #endif
	// ios::sync_with_stdio(false);
	int n;		scanf("%d", &n);
	rep(i, n)	scanf("%d", a+i);
	reverse(a, a+n);
	string m;
	cin>>m;
	reverse(ALL(m));
	// DEBUG(m);
	int i;
	for(i=0; i<SIZE(m); ++i)	if(m[i]=='1')
		break;
	int res = 0;
	for(++i; i<n; ++i)
		res += a[i];
	int r1 = 0;
	rep(i, n)
		r1 += a[i]*(m[i]=='1');
	res = max(res, r1);
	cout << res << "\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define TR(i,v) for(__typeof((v).begin())i=(v).begin();i!=(v).end();++i)
#define DEBUG(x) cout << #x << " = "; cout << x << endl;
#define SIZE(p) (int)(p).size()
#define MP(a, b)	make_pair((a), (b))
#define ALL(p)		(p).begin(), (p).end()
#define rep(i, n)	for(int (i)=0; (i)<(int)(n); ++(i))
#define FOR(i, a, b)   for(int (i)=(int)(a); (i)<=(int)(b); ++(i))
#define FORD(i, b, a)  for(int (i)=(int)(b); (i)>=(int)(a); --(i))
typedef long long LL;
typedef pair<int, int> pii;
int a[100005], psum[100005], n;
int gao(int i)
{
	return psum[n-1]-psum[i];
}
int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
    freopen("C.in", "r", stdin);
    // freopen("out", "w", stdout);
    #endif
	// ios::sync_with_stdio(false);
	scanf("%d", &n);
	rep(i, n)	scanf("%d", a+i);
	reverse(a, a+n);
	rep(i, n)
	{
		if(i==0)	psum[i]=a[i];
		else		psum[i]=psum[i-1]+a[i];
	}
	string m;
	cin>>m;
	reverse(ALL(m));
	int res = 0, c=0;
	rep(i, n)	if(m[i]=='1')
	{
		// DEBUG(res);
		// DEBUG(c);
		res = max(res, c+gao(i));
		c += a[i];
	}
	printf("%d\n", res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define TR(i,v) for(__typeof((v).begin())i=(v).begin();i!=(v).end();++i)
#define DEBUG(x) cout << #x << " = "; cout << x << endl;
#define SIZE(p) (int)(p).size()
#define MP(a, b)	make_pair((a), (b))
#define ALL(p)		(p).begin(), (p).end()
#define rep(i, n)	for(int (i)=0; (i)<(int)(n); ++(i))
#define FOR(i, a, b)   for(int (i)=(int)(a); (i)<=(int)(b); ++(i))
#define FORD(i, b, a)  for(int (i)=(int)(b); (i)>=(int)(a); --(i))
typedef long long LL;
typedef pair<int, int> pii;
int a[100005];
int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
    freopen("C.in", "r", stdin);
    // freopen("out", "w", stdout);
    #endif
	// ios::sync_with_stdio(false);
	int n;		scanf("%d", &n);
	rep(i, n)	scanf("%d", a+i);
	reverse(a, a+n);
	string m;
	cin>>m;
	reverse(ALL(m));
	int i;
	for(i=0; i<SIZE(m); ++i)	if(m[i]=='1')
		break;
	LL res = 0;
	for(++i; i<n; ++i)
		res += a[i];
	LL r1 = 0;
	rep(i, n)
		r1 += a[i]*(m[i]=='1');
	res = max(res, r1);
	printf("%I64d\n", res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define TR(i,v) for(__typeof((v).begin())i=(v).begin();i!=(v).end();++i)
#define DEBUG(x) cout << #x << " = "; cout << x << endl;
#define SIZE(p) (int)(p).size()
#define MP(a, b)	make_pair((a), (b))
#define ALL(p)		(p).begin(), (p).end()
#define rep(i, n)	for(int (i)=0; (i)<(int)(n); ++(i))
#define FOR(i, a, b)   for(int (i)=(int)(a); (i)<=(int)(b); ++(i))
#define FORD(i, b, a)  for(int (i)=(int)(b); (i)>=(int)(a); --(i))
typedef long long LL;
typedef pair<int, int> pii;
int a[100005], psum[100005], n;
int gao(int i)
{
	return psum[n-1]-psum[i];
}
int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
    freopen("C.in", "r", stdin);
    // freopen("out", "w", stdout);
    #endif
	// ios::sync_with_stdio(false);
	scanf("%d", &n);
	rep(i, n)	scanf("%d", a+i);
	reverse(a, a+n);
	rep(i, n)
	{
		if(i==0)	psum[i]=a[i];
		else		psum[i]=psum[i-1]+a[i];
	}
	string m;
	cin>>m;
	reverse(ALL(m));
	int res = 0, c=0;
	rep(i, n)	if(m[i]=='1')
	{
		// DEBUG(res);
		// DEBUG(c);
		res = max(res, c+gao(i));
		c += a[i];
		res = max(res, c);
	}
	printf("%d\n", res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define TR(i,v) for(__typeof((v).begin())i=(v).begin();i!=(v).end();++i)
#define DEBUG(x) cout << #x << " = "; cout << x << endl;
#define SIZE(p) (int)(p).size()
#define MP(a, b)	make_pair((a), (b))
#define ALL(p)		(p).begin(), (p).end()
#define rep(i, n)	for(int (i)=0; (i)<(int)(n); ++(i))
#define FOR(i, a, b)   for(int (i)=(int)(a); (i)<=(int)(b); ++(i))
#define FORD(i, b, a)  for(int (i)=(int)(b); (i)>=(int)(a); --(i))
typedef long long LL;
typedef pair<int, int> pii;
int a[100005];
int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
    freopen("C.in", "r", stdin);
    // freopen("out", "w", stdout);
    #endif
	// ios::sync_with_stdio(false);
	int n;	scanf("%d", &n);
	rep(i, n)	scanf("%d", a+i);
	reverse(a, a+n);
	string m;
	cin>>m;
	reverse(ALL(m));
	int i;
	for(i=0; i<SIZE(m); ++i)	if(m[i]=='1')
		break;
	LL res = 0;
	for(++i; i<n; ++i)
		res += a[i];
	LL res1 = 0;
	rep(i, n)
		res1 += a[i]*(int)(m[i]-'0');
	printf("%I64d\n", max(res, res1));
	return 0;
}


#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <memory>
#include <iomanip>
#include <numeric>
#include <functional>
#include <new>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <cctype>
#include <ctime>

#define REP(i, n) for(int (i) = 0; i < n; i++)
#define FOR(i, a, n) for(int (i) = a; i < n; i++)
#define FORR(i, a, n) for(int (i) = a; i <= n; i++)
#define for_each(q, s) for(typeof(s.begin()) q=s.begin(); q!=s.end(); q++)
#define sz(n) n.size()
#define pb(n) push_back(n)
#define all(n) n.begin(), n.end()

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned uint;

const int MAXN = 100007;

int N;
string str;

int s[MAXN], x[MAXN];

int main(void) {
    N = in();

    int i;

    s[0] = 0;

    for (i = 0; i < N; i++) {
        scanf("%d", &x[i]);

        s[i + 1] = s[i] + x[i];
    }

    cin >> str;

    int ans = 0, curr = 0;

    for (i = N - 1; i >= 0; i--) {
        if (str[i] == '1') {
            ans = max(ans, curr + s[i]);
            curr += x[i];
        }
    }

    printf("%d\n", max(ans, curr));
    return 0;
}


#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <memory>
#include <iomanip>
#include <numeric>
#include <functional>
#include <new>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <cctype>
#include <ctime>

#define REP(i, n) for(int (i) = 0; i < n; i++)
#define FOR(i, a, n) for(int (i) = a; i < n; i++)
#define FORR(i, a, n) for(int (i) = a; i <= n; i++)
#define for_each(q, s) for(typeof(s.begin()) q=s.begin(); q!=s.end(); q++)
#define sz(n) n.size()
#define pb(n) push_back(n)
#define all(n) n.begin(), n.end()

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned uint;

const int MAXN = 100007;

int N;
string str;

int s[MAXN], x[MAXN];

int main(void) {
    N = in();

    int i;

    for (i = 0; i < N; i++) {
        scanf("%d", &x[i]);

        s[i] += x[i];

        if (i > 0) s[i] += s[i - 1];
    }

    cin >> str;

    int ans = 0, curr = 0;

    for (i = N - 1; i >= 0; i--) {
        if (str[i] == '1') {
            ans = max(ans, curr + s[i]);
            curr += x[i];
        }
    }

    printf("%d\n", ans);
    return 0;
}


#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const size_t LIM = 1e+6;

int n, a[LIM];
long long ans, pref[LIM];
string s;

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	cin >> s;
	pref[0] = a[0];
	for (int i = 1; i < n; i++) {
		pref[i] = pref[i - 1] + a[i];
	}
	for (int i = 0; i < (int) s.length(); i++)
		if (s[i] == '1')
			ans += a[i];
	long long res = ans - (s[0] == '1' ? a[0] : 0);
	for (int i = 1; i < n; i++) {
		if (s[i] == '1') {
			res -= a[i];
			ans = max(ans, res + pref[i - 1]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

int calcf(int n, const vector<int> &a, const string&m, int indextoconvtozero) {
  int sum = 0;
  for (int i = 0; i < n; ++i)
  {
    if (i == indextoconvtozero) continue;

    if ('1' == m[i] || i < indextoconvtozero)
    {
      sum += a[i];
    }
  }

  return sum;
}

int main() {

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

  vector<int> a;

  for (int i = 0; i < n; ++i)
  {
    int number;
    scanf("%d", &number);
    a.push_back(number);
  }

  char mm[1000000];
  scanf("%s", mm);
  string m(mm);

  int max = -1;
  //int maxplace = -1;
  for (int indtoconv = -1; indtoconv < n; ++indtoconv)
  {
    if (-1 == indtoconv || '1' == m[indtoconv]) {
      int curr = calcf(n, a, m, indtoconv);

      if (curr > max) {
        max = curr;
        //maxplace = indtoconv;
      }
    }
  }

  cout << max << endl;
  //cerr << max << endl << maxplace << endl;

  return 0;
}


#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

int calcf(int n, const vector<int> &a, const string&m, int indextoconvtozero,
    const vector<int> &sallleft, const vector<int> &sselright
    ) {
  /*int sum = 0;
  for (int i = 0; i < n; ++i)
  {
    if (i == indextoconvtozero) continue;

    if ('1' == m[i] || i < indextoconvtozero)
    {
      sum += a[i];
    }
  }*/
  int sum = 0;
  if (indextoconvtozero > 0) sum += sallleft[indextoconvtozero - 1];
  if (indextoconvtozero < n-1) sum += sselright[indextoconvtozero+1];

  //cerr << indextoconvtozero << ": " << sum << " = " << sallleft[indextoconvtozero] << " + " << sselright[indextoconvtozero+1] << endl;

  return sum;
}

int main() {

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

  vector<int> a;

  for (int i = 0; i < n; ++i)
  {
    int number;
    scanf("%d", &number);
    a.push_back(number);
  }

  char mm[1000000];
  scanf("%s", mm);
  string m(mm);

  vector<int> sallleft;
  sallleft.resize(n);
  int ss = 0;
  for (int i = 0; i < n; ++i)
  {
    ss += a[i];
    sallleft[i] = ss;
  }

  vector<int> sselright;
  sselright.resize(n);
  ss = 0;
  for (int i = n-1; i >=0; --i)
  {
    if ('1' == m[i])
    {
      ss += a[i];
    }
    sselright[i] = ss;
  }

  int max = -1;
  //int maxplace = -1;
  for (int indtoconv = -1; indtoconv < n; ++indtoconv)
  {
    if (-1 == indtoconv || '1' == m[indtoconv]) {
      int curr = calcf(n, a, m, indtoconv, sallleft, sselright);

      if (curr > max) {
        max = curr;
        //maxplace = indtoconv;
      }
    }
  }

  cout << max << endl;
  //cerr << max << endl << maxplace << endl;

  return 0;
}


#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

int calcf(int n, const vector<int> &a, const string&m, int indextoconvtozero) {
  int sum = 0;
  for (int i = 0; i < n; ++i)
  {
    if (i == indextoconvtozero) continue;

    if ('1' == m[i] || i < indextoconvtozero)
    {
      sum += a[i];
    }
  }

  return sum;
}

int main() {

  int n;
  cin >> n;

  vector<int> a;

  for (int i = 0; i < n; ++i)
  {
    int number;
    cin >> number;
    a.push_back(number);
  }

  string m;
  cin >> m;

  int max = -1;
  //int maxplace = -1;
  for (int indtoconv = -1; indtoconv < n; ++indtoconv)
  {
    if (-1 == indtoconv || '1' == m[indtoconv]) {
      int curr = calcf(n, a, m, indtoconv);

      if (curr > max) {
        max = curr;
        //maxplace = indtoconv;
      }
    }
  }

  cout << max << endl;
  //cerr << max << endl << maxplace << endl;

  return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <set>
using namespace std;
#define oo 1000000007
long long int gcd(long long int a,long long int b){
      if(b==0)return a;
      return gcd(b,a%b);
}
long long int a[100005],zero[100005],one[100005];
char m[100005];
int main(int argc, char const *argv[])
{
      int n,temp;
      char temp1;
      scanf("%d",&n);
      long long int ans=0;
      for (int i = 0; i <n; ++i)
      {
            scanf("%lld",&a[i]);
      }

      scanf("%s",m);
      zero[n]=0;
      one[n]=0;
      for (int i = 0; i <=(n-1)/2; ++i)
      {
            temp=a[i];
            a[i]=a[n-i-1];
            a[n-i-1]=temp;
            temp1=m[i];
            m[i]=m[n-i-1];
            m[n-i-1]=temp1;

      }

      for (int i = n-1;i >=0;--i)
      {
            if(m[i]=='1'){
                  one[i]=one[i+1]+a[i];
                  zero[i]=zero[i+1];
            }
            else{
                  one[i]=one[i+1];
                  zero[i]=zero[i+1]+a[i];
            }
      }
      ans=one[0];
      for (int i = 0; i <n; ++i)
      {
            if(m[i]=='1'){
                  ans=max(ans,one[0]-a[i]+zero[i+1]);
            }
      }
      printf("%lld\n",ans);
      return 0;
}


// Written by HadronWave
// P.S. Contains too many bugs.

#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
//-I\O-------------

#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
//-C-libraries------

#include <stack>
#include <deque>
#include <queue>
#include <string>
#include <vector>
#include <map>
#include <set>
//#include <unordered_map>
//-Structs-----------

#include <algorithm>
#include <functional>
//-Other-------------

using namespace std;
//-Using-------------

typedef long long ll;
typedef pair<double,double> prd;
typedef pair<int,int> pr;
//-Typedefs----------

#define double long double
//-Define------------

const ll mod7 = 1000000007;
const ll mod9 = 1000000009;
const int linf = 2000000000;
const ll llinf = 1000000000000000000ll;
//-Const-------------

ifstream in("hyperdrome.in");
ofstream out("hyperdrome.out");
//-File-I/O----------

int arr[10000];
ll data[1000001];
ll sum[1000001];

ll best[1000001];

string s;

ll Solve(int x){
    if(x==-1) return 0ll;
    ll res = Solve(x-1) + (s[x]=='1'?data[x+1]:0);
    if(s[x]=='1')
       res = max(res,sum[x]);
    return res;
}

int main(){

    int n,x;
    cin >> n;
    for(int i=1;i<=n;++i){
        cin >> data[i];
        sum[i]=sum[i-1]+data[i];
    }

    cin >> s;
    int last = -1;
    ll ans = 0;
    int prefix=0;
    for(int i=0;i<s.length();++i){
        if(s[i] == '1')
            last = i;
    }
    if(last==-1) cout << 0;
    else cout << Solve(last);
    return 0;
}


// Written by HadronWave
// P.S. Contains too many bugs.

#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
//-I\O-------------

#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
//-C-libraries------

#include <stack>
#include <deque>
#include <queue>
#include <string>
#include <vector>
#include <map>
#include <set>
//#include <unordered_map>
//-Structs-----------

#include <algorithm>
#include <functional>
//-Other-------------

using namespace std;
//-Using-------------

typedef long long ll;
typedef pair<double,double> prd;
typedef pair<int,int> pr;
//-Typedefs----------

#define double long double
//-Define------------

const ll mod7 = 1000000007;
const ll mod9 = 1000000009;
const int linf = 2000000000;
const ll llinf = 1000000000000000000ll;
//-Const-------------

ifstream in("hyperdrome.in");
ofstream out("hyperdrome.out");
//-File-I/O----------

int arr[10000];
ll data[1000001];
ll sum[1000001];

ll best[1000001];

string s;

ll Solve(int x){
    if(x==-1) return 0ll;
    ll res = Solve(x-1) + (s[x]=='1'?data[x+1]:0);
    res = max(res,sum[x]);
    return res;
}

int main(){

    int n,x;
    cin >> n;
    for(int i=1;i<=n;++i){
        cin >> data[i];
        sum[i]=sum[i-1]+data[i];
    }

    cin >> s;
    int last = -1;
    ll ans = 0;
    int prefix=0;
    for(int i=0;i<s.length();++i){
        if(s[i] == '1')
            last = i;
    }
    if(last==-1) cout << 0;
    else cout << Solve(last);
    return 0;
}


#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <list>
#include <fstream>
#include <time.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <complex>
#include <limits.h>
#include <cassert>

using namespace std;

#define For(i,a,b,d) for (int i = (a); i != (b); i += d)
#define FORD(i,a,b) for (int i = (a); i >= b; i--)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define REPD(i,n) for (int i = (n - 1); i >= 0; i--)
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define CLR(a,x) memset(a,x,sizeof(a))
#define debug(x) cout << #x << "=" << x << endl;
#define pb push_back
#define mp make_pair

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int mx[4] = {1, -1, 0, 0};
const int my[4] = {0, 0, 1, -1};

const int Inf = 2000000000;
const int Mi = 1000000009;
const int N = 100005;
const int K = 3005;
const ld eps = 10e-6;
const ld PI = 2 * acos(0.0);
const ll InfLL = ll(Inf) * ll(Inf);

ll gcd(ll a, ll b) {
    if (!b) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}

int a[N], sum[N];
int n;
int ans;
string s;

void func(int pos, int csum) {
    if (pos == -1) {
        ans = max(ans, csum);
        return;
    }
    REP(i, 2) {
        if (i < s[pos] - '0') {
            ans = max(ans, csum + (pos > 0 ? sum[pos - 1] : 0));
        } else if (i == s[pos] - '0') {
            func(pos - 1, csum + i * a[pos]);
        }
    }
}

//#define ONLINE_JUDGE
int main () {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n;
    REP(i, n) {
        cin >> a[i];
        sum[i] = a[i] + (i > 0 ? sum[i - 1] : 0);
    }
    cin >> s;
    func(n - 1, 0);
    cout << ans;
    return 0;
}


#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <list>
#include <fstream>
#include <time.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <complex>
#include <limits.h>
#include <cassert>

using namespace std;

#define For(i,a,b,d) for (int i = (a); i != (b); i += d)
#define FORD(i,a,b) for (int i = (a); i >= b; i--)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define REPD(i,n) for (int i = (n - 1); i >= 0; i--)
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define CLR(a,x) memset(a,x,sizeof(a))
#define debug(x) cout << #x << "=" << x << endl;
#define pb push_back
#define mp make_pair

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int mx[4] = {1, -1, 0, 0};
const int my[4] = {0, 0, 1, -1};

const int Inf = 2000000000;
const int Mi = 1000000009;
const int N = 205;
const int K = 3005;
const ld eps = 10e-6;
const ld PI = 2 * acos(0.0);
const ll InfLL = ll(Inf) * ll(Inf);

ll gcd(ll a, ll b) {
    if (!b) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}

int a[N], sum[N];
int n;
int ans;
string s;

void func(int pos, int csum) {
    if (pos == -1) {
        ans = max(ans, csum);
        return;
    }
    REP(i, 2) {
        if (i < s[pos] - '0') {
            ans = max(ans, csum + (pos > 0 ? sum[pos - 1] : 0));
        } else if (i == s[pos] - '0') {
            func(pos - 1, csum + i * a[pos]);
        }
    }
}

//#define ONLINE_JUDGE
int main () {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n;
    REP(i, n) {
        cin >> a[i];
        sum[i] = a[i] + (i > 0 ? sum[i - 1] : 0);
    }
    cin >> s;
    func(n - 1, 0);
    cout << ans;
    return 0;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    int n,a[100005],c[100005]={0},mx=0;
    char s[100005];
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>a[i];
        c[i+1]=c[i]+a[i];
    }
    cin>>s;
    for (int i=0; i<n; i++) {
        if (s[i]=='0') {
            continue;
        }
        if (mx+a[i]>c[i]) {
            mx+=a[i];
        }
        else {
            mx=c[i];
        }
    }
    cout<<mx<<endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstddef>
#include <complex>
#include <ctime>
#include <climits>

#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <functional>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <memory>

#include <cassert>

#if __cplusplus >= 201103L
#include <tuple>
#include <ratio>
#include <array>
#include <forward_list>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long int64;
const int inf = 2000000000;
static inline int Rint()
{
	struct X{ int dig[256]; X(){
	for(int i = '0'; i <= '9'; ++i) dig[i] = 1; dig['-'] = 1;
	}};
	static 	X fuck;int s = 1, v = 0, c;
	for (;!fuck.dig[c = getchar()];);
	if (c == '-') s = 0; else if (fuck.dig[c]) v = c ^ 48;
	for (;fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48));
	return s ? v : -v;
}
typedef vector<int> vi;
typedef map<int, int> mii;
typedef set<int> si;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i, s, e) for (int i = (s); i < (e); ++i)

#if __cplusplus >= 201103L
#define foreach(iter, c) for(auto& iter : c)
#else
#define foreach(itr, c) for(__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); ++itr)
#endif

template<typename T> static inline void cmax(T& a, const T& b){if(b>a)a=b;}
template<typename T> static inline void cmin(T& a, const T& b){if(b<a)a=b;}
#define SL static inline

#define dbg(x) cerr << (#x) << " = " << (x) << endl

const int maxn = 100005;
int data[maxn];
int ps[maxn];
char flag[maxn];
int main()
{
	const int n = Rint();
	for (int i = 1; i <= n; ++i)
	data[i] = Rint();
	partial_sum(data, data+1+n, ps);
	scanf("%s", flag+1);

	int one = n;
	while (one >= 1 && flag[one] == '0') --one;
	if (one == 0)
	{
		puts("0");
		return 0;
	}
	int ans = 0;
	int prev = 0;
	for (int i = one; i >= 1; --i)
	if (flag[i] == '1')
	{
		int u = prev + ps[i-1];
		if (u > ans) ans = u;
		prev += data[i];
	}
	if (prev > ans) ans = prev;
	cout << ans << endl;
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;

    scanf("%d",&n);
    int i=0;
    int  tempsum=0;
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        tempsum+=arr[i];
    }
    getchar();
    char bol[n];

    gets(bol);
    int flag =0,index;
    int  max=0,counter=0;
    for(i=n-1;i>=0;i--)
    {
        if(flag==0&&bol[i]=='1')
        {
            index=i;
            flag=1;
        }
        else if(flag==0)
            tempsum-=arr[i];
        if(bol[i]=='1')
            {
                max+=arr[i];
                counter++;
            }
    }
    for(i=index;(i>=0&&max!=0&&counter!=n);i--)
    {
        if(((tempsum-arr[i])>=max)&&bol[i]=='1')
        {
            max=tempsum-arr[i];
        }
        else if (bol[i]=='0')
        {
            tempsum-=arr[i];
        }

    }
    printf("%d",max);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;

    scanf("%d",&n);
    int i=0;
    int  tempsum=0;
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        tempsum+=arr[i];
    }
    getchar();
    char bol[n];

    gets(bol);
    int flag =0,index;
    int  max=0;
    for(i=n-1;i>=0;i--)
    {
        if(flag==0&&bol[i]=='1')
        {
            index=i;
            flag=1;
        }
        else if(flag==0)
            tempsum-=arr[i];
        if(bol[i]=='1')
            max+=arr[i];
    }
    for(i=index;i>=0;i--)
    {
        if(((tempsum-arr[i])>=max)&&bol[i]=='1')
        {
            max=tempsum-arr[i];
        }
        else if (bol[i]=='0')
        {
            tempsum-=arr[i];
        }

    }
    printf("%d",max);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    int i=0,tempsum=0;
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        tempsum+=arr[i];
    }
    getchar();
    char bol[n];

    gets(bol);
    int flag =0,max=0,max2=0,index;
    for(i=n-1;i>=0;i--)
    {
        if(flag==0&&bol[i]=='1')
        {
            index=i;
            flag=1;
        }
        else if(flag==0)
            tempsum-=arr[i];
        if(bol[i]=='1')
            max+=arr[i];
    }
    int temp=0;
    for(i=index;i>=0;i--)
    {
        if(((tempsum-arr[i])>=max)&&bol[i]=='1')
        {
            max=tempsum-arr[i];
            temp+=arr[i];
        }
        else if (bol[i]=='0')
        {
            tempsum-=(temp+arr[i]);
        }

    }
    printf("%d",max);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main()
{
    int n;

    scanf("%d",&n);
    int i=0;
    long long tempsum=0;
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        tempsum+=arr[i];
    }
    getchar();
    char bol[n];

    gets(bol);
    int flag =0,index;
    long long max=0;
    for(i=n-1;i>=0;i--)
    {
        if(flag==0&&bol[i]=='1')
        {
            index=i;
            flag=1;
        }
        else if(flag==0)
            tempsum-=arr[i];
        if(bol[i]=='1')
            max+=arr[i];
    }
    long long temp= LONG_LONG_MAX;
    flag=0;
    for(i=index;i>=0;i--)
    {
        if(((tempsum-arr[i])>=max)&&bol[i]=='1')
        {
            max=tempsum-arr[i];
        }
        else if (bol[i]=='0')
        {
            tempsum-=arr[i];
        }

    }
    printf("%I64d",max);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;

    scanf("%d",&n);
    int i=0;
    int  tempsum=0;
    int arr[n+10];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        tempsum+=arr[i];
    }
    getchar();
    char bol[n+10];

    gets(bol);
    int flag =0,index;
    int  max=0,counter=0;
    for(i=n-1;i>=0;i--)
    {
        if(flag==0&&bol[i]=='1')
        {
            index=i;
            flag=1;
        }
        else if(flag==0)
            tempsum-=arr[i];
        if(bol[i]=='1')
            {
                max+=arr[i];
                counter++;
            }
    }
    for(i=index;(i>=0&&max!=0&&counter!=n);i--)
    {
        if(((tempsum-arr[i])>=max)&&bol[i]=='1')
        {
            max=tempsum-arr[i];
        }
        else if (bol[i]=='0')
        {
            tempsum-=arr[i];
        }

    }
    printf("%d",max);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    int i=0;
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    getchar();
    char bol[n];

    gets(bol);
    int flag =0,max=0,max2=0,index;
    for(i=n-1;i>=0;i--)
    {
        if(flag==0&&bol[i]=='1')
        {
            index=i-1;
            flag=1;
        }

        if(bol[i]=='1')
            max+=arr[i];
    }
    for(i=index;i>=0;i--)
    {
        max2+=arr[i];
    }
    if(max2>=max)
        printf("%d",max2);
    else
        printf("%d",max);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;

    scanf("%d",&n);
    int i=0;
    int  tempsum=0;
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        tempsum+=arr[i];
    }
    getchar();
    char bol[n];

    gets(bol);
    int flag =0,index;
    int  max=0;
    for(i=n-1;i>=0;i--)
    {
        if(flag==0&&bol[i]=='1')
        {
            index=i;
            flag=1;
        }
        else if(flag==0)
            tempsum-=arr[i];
        if(bol[i]=='1')
            max+=arr[i];
    }
    for(i=index;i>=0&&max!=0;i--)
    {
        if(((tempsum-arr[i])>=max)&&bol[i]=='1')
        {
            max=tempsum-arr[i];
        }
        else if (bol[i]=='0')
        {
            tempsum-=arr[i];
        }

    }
    printf("%d",max);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define MAX_N 100001

int main(void) {
	int n,i;
	int *a;
	char *m;

	long zerosum=0,max=0;

	a=(int*)malloc(MAX_N*sizeof(int));
	m=(char*)malloc(MAX_N*sizeof(char));

	scanf("%d",&n);
	for(i=0;i<n;++i) scanf("%d",&a[i]);
	scanf("%s",m);

	for(i=0;i<n;++i) {
		if(m[i]=='0') zerosum+=a[i];
		else {
			if(zerosum>a[i]){ max+=zerosum; zerosum=a[i]; }
			else max+=a[i];
		}
	}

	printf("%ld",max);
	free(a);
	free(m);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define MAX_N 100001

int main(void) {
	int n,i;
	int *a;
	char *m;

	long zerosum=0,max=0;

	a=(int*)malloc(MAX_N*sizeof(int));
	m=(char*)malloc(MAX_N*sizeof(char));

	scanf("%d",&n);
	for(i=0;i<n;++i) scanf("%d",&a[i]);
	scanf("%s",m);

	for(i=0;i<n;++i) {
		if(m[i]=='0') zerosum+=a[i];
		else {
			if(zerosum>a[i]) max+=zerosum;
			else max+=a[i]; zerosum=0;
		}
	}

	printf("%ld",max);
	free(a);
	free(m);

	return 0;
}


#include <stdlib.h>
#include <stdio.h>

int main()
{
	int n, *data, *bits;
	scanf("%d", &n);
	int i, maxset=-1;
	char *string = malloc(sizeof(char)*(n+1));
	data = malloc(sizeof(int)*n);
	bits = malloc(sizeof(int)*n);
	for(i=n-1;i>=0;i--) scanf("%d", &data[i]);
	scanf("%s", string);
	int tempsum=0;
	for(i=0;i<n;i++)
	{
	 	if(string[n-i-1]=='0') bits[i] = 0;
		else bits[i] = 1;
		if((bits[i]==1) && (maxset==-1)) maxset = i;
		tempsum += bits[i]*data[i];
	}
	if(maxset == -1) {printf("0\n"); return 0;}
	int minsum = 0;
	for(i=maxset+1;i<n;i++) minsum += data[i];
	if(tempsum > minsum) minsum = tempsum;
	int *sumarray = malloc(sizeof(int)*(n+1));
	sumarray[n] = 0;
	for(i=n-1;i>=0;i--) sumarray[i] = sumarray[i+1] + data[i];
	int finalsum = minsum;
	int flysum=0;
	for(i=maxset;i<n;i++)
	{
		if(bits[i]==1)
		{
			if((flysum + sumarray[i+1])>finalsum) finalsum = flysum + sumarray[i+1];
			flysum += data[i];
		}
	}
	printf("%d\n", finalsum);
	return 0;
}


#include <stdlib.h>
#include <stdio.h>

int main()
{
	int n, *data, *bits;
	scanf("%d", &n);
	int i, maxset=-1;
	char *string = malloc(sizeof(char)*(n+1));
	data = malloc(sizeof(int)*n);
	bits = malloc(sizeof(int)*n);
	for(i=n-1;i>=0;i--) scanf("%d", &data[i]);
	scanf("%s", string);
	int tempsum=0;
	for(i=0;i<n;i++)
	{
	 	if(string[n-i-1]=='0') bits[i] = 0;
		else bits[i] = 1;
		if((bits[i]==1) && (maxset==-1)) maxset = i;
		tempsum += bits[i]*data[i];
	}

	int minsum = 0;
	for(i=maxset+1;i<n;i++) minsum += data[i];
	if(tempsum > minsum) minsum = tempsum;
	int *sumarray = malloc(sizeof(int)*(n+1));
	sumarray[n] = 0;
	for(i=n-1;i>=0;i--) sumarray[i] = sumarray[i+1] + data[i];
	int finalsum = minsum;
	int flysum=0;
	for(i=maxset;i<n;i++)
	{
		if(bits[i]==1)
		{
			if((flysum + sumarray[i+1])>finalsum) finalsum = flysum + sumarray[i+1];
			flysum += data[i];
		}
	}
	printf("%d\n", finalsum);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n, *x, *y;
	scanf("%d", &n);
	int i;
	x = malloc(sizeof(int)*n);
	y = malloc(sizeof(int)*n);
	for(i=0;i<n;i++) scanf("%d %d", &x[i], &y[i]);

	int sumx=0, sumy=0;
	for(i=0;i<n;i++) sumx += x[i];
	for(i=0;i<n;i++) sumy += y[i];

	if((sumx%2==0) && (sumy%2==0)) printf("0\n");
	else if((sumx%2==1) && (sumy%2==1))
	{
		int found=0;
		for(i=0;i<n;i++)
			if(((x[i]%2)^(y[i]%2))==1) found=1;
		if(found==1) printf("1\n");
		else printf("-1\n");
	}
	else printf("-1\n");
	return 0;
}


#include <stdlib.h>
#include <stdio.h>

int main()
{
	int n, *data, *bits;
	scanf("%d", &n);
	int i, maxset=0;
	char *string = malloc(sizeof(char)*(n+1));
	data = malloc(sizeof(int)*n);
	bits = malloc(sizeof(int)*n);
	for(i=n-1;i>=0;i--) scanf("%d", &data[i]);
	scanf("%s", string);
	int tempsum=0;
	for(i=0;i<n;i++)
	{
	 	if(string[n-i-1]=='0') bits[i] = 0;
		else bits[i] = 1;
		if((bits[i]==1) && (maxset==0)) maxset = i;
		tempsum += bits[i]*data[i];
	}

	int minsum = 0;
	for(i=maxset+1;i<n;i++) minsum += data[i];
	if(tempsum > minsum) minsum = tempsum;
	int *sumarray = malloc(sizeof(int)*(n+1));
	sumarray[n] = 0;
	for(i=n-1;i>=0;i--) sumarray[i] = sumarray[i+1] + data[i];
	int finalsum = minsum;
	int flysum=0;
	for(i=maxset;i<n;i++)
	{
		if(bits[i]==1)
		{
			if((flysum + sumarray[i+1])>finalsum) finalsum = flysum + sumarray[i+1];
			flysum += data[i];
		}
	}
	printf("%d\n", finalsum);
	return 0;
}


#include <stdio.h>

int main(void)
{
	static int a[100000];
	static long long s[100000 + 1];
	static char m[100000 + 1];
	int n, i;
	long long sum, answer;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		scanf("%d ", &a[i]);
	gets(m);

	for (i = 0; i < n; ++i)
		s[i + 1] = s[i] + a[i];

	sum = 0;
	answer = 0;
	for (i = n - 1; i >= 0; --i)
	{
		if (m[i] == '1')
		{
			long long candidate = sum + s[i];
			if (candidate > answer)
				answer = candidate;
			sum += a[i];
		}
	}
	if (sum > answer)
		answer = sum;

	printf("%I64d\n", answer);
	return 0;
}


#include<stdio.h>
int main()
{
    int n,i,j,l,k,p,q;
    long int sum,max;
    scanf("%d",&n);
    int a[n];
    char m[n];
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    scanf(" %s",m);
    max=0;
    sum=0;
    for(i=0;i<n;i++)sum+=a[i]*(m[i]-48);
    if(sum>max)max=sum;

    for(l=1;l<n;l++)
    {
        p=m[l]-48;
        q=m[l-1]-48;
        if(p && q==0)
        {
            sum-=a[l];
            m[l]=48;
            for(j=l-1;j>-1;j--)
            {
                if (m[j]-48)break;
                sum+=a[j];
                m[j]=49;
            }
            //printf("%s\n",m);
            //printf("sum=%d\n",sum);
            //scanf("%d",&i);
            if(sum>max)max=sum;
        }
    }
    printf("%ld",max);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,j,l,k,p,q;
    int sum,max;
    scanf("%d",&n);
    int a[n],s[n];
    char m[n];
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    scanf(" %s",m);
    for(i=0;i<n;i++)s[i]=m[i]-48;
    max=0;
    sum=0;
    for(i=0;i<n;i++)sum+=a[i]*(s[i]);
    if(sum>max)max=sum;

    for(l=1;l<n;l++)
    {
        p=s[l];
        q=s[l-1];
        if(p && q==0)
        {
            sum-=a[l];
            s[l]=0;
            for(j=l-1;j>-1;j--)
            {
                if (s[j])break;
                sum+=a[j];
                s[j]=1;
            }
            if(sum>max)max=sum;
        }
    }
    printf("%d",max);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,j,l,k,p,q;
    long int sum,max;
    scanf("%d",&n);
    long int a[n];
    char m[n];
    for(i=0;i<n;i++)scanf("%ld",&a[i]);
    scanf(" %s",m);
    max=0;
    sum=0;
    for(i=0;i<n;i++)sum+=a[i]*(m[i]-48);
    if(sum>max)max=sum;

    for(l=1;l<n;l++)
    {
        p=m[l]-48;
        q=m[l-1]-48;
        if(p && q==0)
        {
            sum-=a[l];
            m[l]=48;
            for(j=l-1;j>-1;j--)
            {
                if (m[j]-48)break;
                sum+=a[j];
                m[j]=49;
            }
            if(sum>max)max=sum;
        }
    }
    printf("%ld",max);
    return 0;
}


#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#define __USE_MINGW_ANSI_STDIO 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#include<string>
#include<map>
#include<bitset>
#include <math.h>
#include<queue>
#include<complex>
#include<ctime>
#include<cctype>
#include<list>
#define ll long long
#define is_bit(a,b) (a&(1<<b))
using namespace std;
string s,s1,s2,ans,p;
int n;
int a[26];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
 //freopen("four.in", "r", stdin);
 //freopen("four.out", "w", stdout);
cin>>n>>s;
for(int i=0;i<n;i++)
a[s[i]-'a']++;
for(int i=0;i<26;i++)
for(int j=0;j<a[i];j++)
cout<<(char)('a'+i);
  return 0;
}


#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#define __USE_MINGW_ANSI_STDIO 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#include<string>
#include<map>
#include<bitset>
#include <math.h>
#include<queue>
#include<complex>
#include<ctime>
#include<cctype>
#include<list>
#define ll long long
#define is_bit(a,b) (a&(1<<b))
using namespace std;
string s,s1,s2,ans,p;
int n;
int a[26];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
 //freopen("four.in", "r", stdin);
 //freopen("four.out", "w", stdout);
cin>>n>>s;
int kol=0;
for(int i=0;i<n;i++)
a[s[i]-'a']++;
for(int i=0;i<26;i++)
{
    kol+=(a[i]/2)*2;
    for(int j=0;j<a[i]/2;j++)
    s1+='a'+i;
    a[i]-=(a[i]/2)*2;
    if(a[i])
    p+='a'+i;
}
s2=s1;
reverse(s2.begin(),s2.end());
if(n&1)
{
    if(p.size()>1)
    ans=p.substr(0,p.size()/2);
    ans+=s1;
    ans+=p[p.size()/2];
    ans+=s2;
    for(int i=p.size()/2+1;i<p.size();i++)
    ans+=p[i];
}
else
{
       if(p.size()>1)
    ans=p.substr(0,p.size()/2);
    ans+=s1;
    ans+=s2;
    for(int i=p.size()/2;i<p.size();i++)
    ans+=p[i];
}
cout<<ans;
  return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <fstream>
#define ll long long int
using namespace std;
const double _pi = acos(-1.0);
int main()
{
    //freopen("in.txt", "r", stdin);
	int n;
	scanf("%d\n", &n);
	string s;
	getline(cin, s);
	sort(s.begin(), s.end());
	printf("%s\n", s.c_str());
    return 0;
}


#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

/*
 *
 */

int n;
string s;
int fr[200];
int main(int argc, char** argv) {
    cin >> n;
    cin >> s;
    sort(s.begin(), s.end());
    cout << s;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<string>
#include<map>
#include<set>
using namespace std;
#define int long long
#define fi(i,a,b) for(int i = a; i < (b) ;i++)
const int N = 200005;

int a[524];

void main() {
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n; cin >> n; string s; cin >> s;
	int res = 0;
	fi(i, 0, n) {
		a[s[i]]++;
		res += a[s[i]];
	}
	for (char c = 'a'; c <= 'z'; c++) {
		for (int i = 0; i < a[c]; i++) cout << c;
	}
}


#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
char a[100005], n;
bool lf(char x, char y) {
    return (x>y);
}
int main() {
    cin>>n;
    cin>>a;
    sort(a+0, a+n, lf);
    for(int i=0; i<n; i++) cout<<a[i];
}


#include<iostream>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<stdio.h>
using namespace std;
string a;
bool lf(int x, int y) {
    return (int(a[x])<int(a[y]));
}
int cs[100005], n;
int main() {
    cin>>n;
    fflush(stdin);
    getline(cin, a);
    for(int i=0; i<n; i++) cs[i]=i;
    sort(cs+0, cs+n, lf);
    for(int i=0; i<n; i++) cout<<a[cs[i]];
}


#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
char a[100005], n;
bool lf(char x, char y) {
    return (x>y);
}
int main() {
    cin>>n;
    cin>>a;
    sort(a+0, a+n, lf);
    cout<<a;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
#include<stdio.h>
using namespace std;
string a;
bool lf(int x, int y) {
    return (int(a[x])<int(a[y]));
}
int cs[100005], n;
int main() {
    cin>>n;
    cin>>a;
    for(int i=0; i<n; i++) cs[i]=i;
    sort(cs+0, cs+n, lf);
    for(int i=0; i<n; i++) cout<<a[cs[i]];
}


#include<iostream>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<stdio.h>
using namespace std;
string a;
bool lf(int x, int y) {
    return (int(a[x])<int(a[y]));
}
int cs[100005], n;
int main() {
    cin>>n;
    cin>>a;
    for(int i=0; i<n; i++) cs[i]=i;
    sort(cs+0, cs+n, lf);
    for(int i=0; i<n; i++) cout<<a[cs[i]];
}


#include<iostream>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<stdio.h>
using namespace std;
string a;
bool lf(int x, int y) {
    return (int(a[x])<int(a[y]));
}
int cs[100005], n;
int main() {
    cin>>n;
    fflush(stdin);
    cin>>a; fflush(stdin);
    for(int i=0; i<n; i++) cs[i]=i;
    sort(cs+0, cs+n, lf);
    for(int i=0; i<n; i++) cout<<a[cs[i]];
}


#include <iostream>
#include <unordered_map>

using namespace std;

typedef unordered_map<char, int> um;
int main()
{
	int n;
	char ch;
	um m;
	cin >> n;
	cin.get();
	for (int i = 0; i < n; i++)
	{
		cin >> ch;
		m[ch]++;
	}
	for (um::iterator iter = m.begin(); iter != m.end(); iter++)
	{
		for (int i = 0; i < (*iter).second; i++)
			cout << (*iter).first;
	}
	return 0;
}


#include<cstdio>
#include<string>
#include<vector>

using namespace std;

int main()
{
	int n;
	char input[100001];
	int i, j;
	int cnt[26] = { 0, };
	string s, sol;
	string part1, paste;
	vector<pair<int,int>> even, odd;

	scanf("%d", &n);

	scanf("%s", input);

	s = input;

	for (i = 0; i < n; i++)
	{
		cnt[s[i] - 'a']++;
	}
	/*
	for (i = 0; i < 26; i++)
	{
		if (cnt[i])
		{
			if (cnt[i] % 2)
			{
				even.push_back(pair<int,int>(i,cnt[i]));
			}

			else
			{
				odd.push_back(pair<int, int>(i, cnt[i]));
			}
		}
	}

	if (even.size() == odd.size())
	{
		for (i = 0; i < even.size(); i++)
		{
			for(j=0;j<e)
		}
	}
	*/

	for (i = 0; i < 26; i++)
	{
		for (j = 0; j < cnt[i]; j++)
		{
			printf("%c", i + 'a');
		}
	}

	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
char st[110000];
bool cmp(char a,char b)
{
	return a<b;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",st+1);
	sort(st+1,st+n+1,cmp);
	printf("%s",st+1);
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
using namespace std;
int i,j,k,m,n,a[100041],p;
char s[105000];
int main()
{

	cin>>n;
	cin>>s;
	for(i=0;i<n;i++)
		a[s[i]-'a']++;
	for(i=0;i<26;i++)
	{
		for(j=0;j<a[i];j++)
			cout<<(char)(i+'a');
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cmath>
#define inf 0x7f7f7f7f7f7f7f7f
using namespace std;
typedef long long LL;
int main()
{
    LL n,i,j;
    LL a[27];
    char alph[27];
    char tmp;
    scanf("%I64d", &n);
    for(i=0;i<26;i++){
        a[i]=0;
        alph[i]='a'+i;
    }
    scanf("%c", &tmp);
    while(n--){
        scanf("%c", &tmp);
        i = tmp-'a';
        a[i]++;
    }
    for(i=0;i<26;i++)
        for(j=0;j<a[i];j++)
            printf("%c", alph[i]);
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
using namespace std;

int n;
char s[200010],b[100];

int main()
{
	cin>>n;
	scanf("%s",s);
	memset(b,0,sizeof(b));
	for(int i=0;i<n;i++)
		b[s[i]-'a']++;
	for(int i=0;i<26;i++)
	{
		while(b[i]--)
			printf("%c",'a'+i);
	}
	cout<<endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
using namespace std;

int n;
char a[100010],b[30];

int main()
{
	cin>>n;
	scanf("%s",a);
	for(int i=0;i<n;i++)
		b[a[i]-'a']++;
	for(int i=0;i<26;i++)
	{
		if(b[i]!=0)
		{
			for(int j=1;j<=b[i];j++)
				printf("%c",'a'+i);
		}
		else continue;
	}
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
using namespace std;

int n;
char s[200010];

int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++)
		cout<<s[i];
	cout<<endl;
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
using namespace std;

int n;
char a[100010],b[30];

int main()
{
	cin>>n;
	scanf("%s",a);
	memset(b,0,sizeof(b));
	for(int i=0;i<n;i++)
		b[a[i]-'a']++;
	for(int i=0;i<26;i++)
	{
		while(b[i]--)
			printf("%c",'a'+i);
	}
	cout<<endl;
	return 0;
}


#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <set>
#include <list>
#include <ctime>
#include <bitset>
#include <deque>
#include <iomanip>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <stack>

#define setzero(arr) memset(arr, 0, sizeof(arr))
#define fi(i, from, to) for(int i = (from); i < (to); i++)
#define fri(i, from, to) for(int i = (from); i >= (to); i--)
#define fa(it, col) for(auto (it) = (col).begin(); (it) != (col).end(); (it)++)
#define fra(it, col) for(auto (it) = (col).rbegin(); (it) != (col).rend(); (it)++)
#define getBit(vv, bit) ((vv & (lol)(1LL << (31 - bit))) == 0LL ? 0 : 1)
#define getBit64(vv, bit) ((vv & (lol)(1LL << (63 - bit))) == 0LL ? 0 : 1)
#define MOD 1000000007
#define PI 3.14159265358979323846

using namespace std;
typedef unsigned long long lol;
typedef  long long slol;

#define MAX_VAL 100000000

string str;
int cnts[30];
char ans[101000]; int a_pos = 0;

int main() {

#if  defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	cin >> str;

	fi(i, 0, n)
	{
		cnts[str[i] - 'a']++;
	}

	fi(i, 0, 30)
	{
		while (cnts[i] > 0)
		{
			cnts[i]--;
			ans[a_pos++] = 'a' + i;
		}
	}

	cout << ans;

	return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <assert.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	string s, t;
	cin >> n >> s;
	sort(s.begin(), s.end());
	cout << s;
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	sort(s.begin(), s.end());
	cout << s;
	return 0;
}


#include <iostream>
#include<cmath>

using namespace std;

int main(){
    int n;
    cin>>n;
char a[100001];
for(int i=0;i<n;i++){
    cin>>a[i];
}

for(int i=0;i<n;i++){
    for(int j=n-1;j>i;j--){
if(a[j]>a[j-1])
    swap(a[j],a[j-1]);
    }
}
cout<<endl;
for(int i=0;i<n;i++)
    cout<<a[i];

return 0;
}


#include <iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin>>n;
char a[100001];
for(int i=0;i<n;i++){
    cin>>a[i];
}
sort(a,a+n);

for(int i=0;i<n;i++)
    cout<<a[i];

return 0;
}


#include<iostream>
using namespace std;
int n,sum[35],num=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	  char ch;
	  cin>>ch;
	  ++sum[(int)((int)ch-(int)'a')];
	}
	for(int i=0;i<=30;i++)
	  while(sum[i]!=0)
	  {
	  	cout<<(char)(i+(int)'a');
	  	--sum[i];
	  	++num;
	  	if(num==n)return 0;
	  }
	return 0;
}


#include<iostream>
using namespace std;
int n,sum[30];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	  char ch;
	  cin>>ch;
	  ++sum[(ch-'a')];
	}
	for(int i=0;i<=30;i++)
	  while(sum[i]!=0)
	  {
	  	cout<<(char)(i+'a');
	  	--sum[i];
	  }
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxN=(int)1e5+7;
char s[maxN];
int n;
int main(){
    scanf("%d",&n);
    scanf("%s",s);
    sort(s,s+n);
    printf("%s",s);

}


#if 1
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<cstring>
#include<cstdlib>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ar[30];
    for(int i = 0; i < 30; i++)
        ar[i] = 0;
    for(int i = 0; i < n; i++){
        ar[s[i] - 'a'] ++;
    }
    for(int i= 0; i < 30; i++){
        for(int j = 0; j < ar[i]; j++){
            cout << char('a' + i);
        }
    }
    cout << endl;
    return 0;
}

#endif
/*

 */


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
template <typename T> inline void read(T &l)
{
    l=0;
    int w=1;
    char ch=0;
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
        w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        l=(l<<1)+(l<<3)+(ch-'0');
        ch=getchar();
    }
    l*=w;
}
int n;
string s;
int num[26];
int main()
{
    read(n);
    cin>>s;
    for(int i=0;i<n;i++)
    num[s[i]-'a']++;
    for(int i=0;i<26;i++)
    {
        char x=i+'a';
        if(num[i]!=0)
        for(int j=1;j<=num[i];j++)
        cout<<x;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
template <typename T> inline void read(T &l)
{
    l=0;
    int w=1;
    char ch=0;
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
        w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        l=(l<<1)+(l<<3)+(ch-'0');
        ch=getchar();
    }
    l*=w;
}
int n;
string s;
int num[260];
int main()
{
    read(n);
    cin>>s;
    for(int i=0;i<=n;i++)
    num[s[i]-'a']++;
    for(int i=0;i<26;i++)
    {
        char x=i+'a';
        if(num[i]!=0)
        for(int j=1;j<=num[i];j++)
        cout<<x;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
template <typename T> inline void read(T &l)
{
    l=0;
    int w=1;
    char ch=0;
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
        w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        l=(l<<1)+(l<<3)+(ch-'0');
        ch=getchar();
    }
    l*=w;
}
int n;
string s;
int num[26];
int main()
{
    read(n);
    cin>>s;
    for(int i=0;i<=n;i++)
    num[s[i]-'a']++;
    for(int i=0;i<26;i++)
    {
        char x=i+'a';
        if(num[i]!=0)
        for(int j=1;j<=num[i];j++)
        cout<<x;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
template <typename T> inline void read(T &l)
{
    l=0;
    int w=1;
    char ch=0;
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
        w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        l=(l<<1)+(l<<3)+(ch-'0');
        ch=getchar();
    }
    l*=w;
}
int n;
string s;
int num[260];
int main()
{
    cin>>n>>s;
    for(int i=0;i<=n;i++)
    num[s[i]-'a']++;
    for(int i=0;i<26;i++)
    {
        char x=i+'a';
        if(num[i]!=0)
        for(int j=1;j<=num[i];j++)
        cout<<x;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;
int n;
string s;
int num[260];
int main()
{
    cin>>n;
    cin>>s;
    for(int i=0;i<=n;i++)
    num[s[i]-'a']++;
    for(int i=0;i<26;i++)
    {
        char x=i+'a';
        if(num[i]!=0)
        for(int j=1;j<=num[i];j++)
        cout<<x;
    }
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    char s[100005];
    char c;
    scanf("%c",&c);
    for(int i=0;i<n;i++)
    {
        scanf("%c",&s[i]);
    }
    sort(s,s+n);
    for(int i=0;i<n;i++)
    {
        printf("%c",s[i]);
    }
    printf("\n");
    return 0;
}


#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
long long a[124];
int main(){
long long b;
cin>>b;
string s;
fflush(stdin);
getline(cin,s);
for (int i=0;i<s.length();i++)
	for (int j1=97;j1<123;j1++) if (int(s[i])==j1)
	a[j1]+=1;
for (int j=97;j<123;j++) if(a[j]>0) for (int i=0;i<a[j];i++) cout<<char(j);
return 0;
}


#include<iostream>
#include<string>
using namespace std;
long long a[124];
int main(){
long long b;
cin>>b;
string s;
cin.ignore(1000,'\n');
getline(cin,s);
for (int i=0;i<s.length();i++)
	for (int j1=97;j1<123;j1++) if (int(s[i])==j1)
	a[j1]+=1;
for (int j=97;j<123;j++) if(a[j]>0) for (int i=0;i<a[j];i++) cout<<char(j);
return 0;
}


#include<iostream>
#include<fstream>
#include<string>
#include<stdio.h>
using namespace std;
long long a[124];
ifstream inf;
int main(){
long long b;
cin>>b;
string s;
fflush(stdin);
getline(cin,s);
for (int i=0;i<s.length();i++)
	for (int j1=97;j1<123;j1++) if (int(s[i])==j1)
	a[j1]+=1;
for (int j=97;j<123;j++) if(a[j]>0) for (int i=0;i<a[j];i++) cout<<char(j);
inf.close();
return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <math.h>
#include <string>

using namespace std;

typedef long long ll;

#define INF 1000000000

int main() {
	int n; cin >> n;
	string a;
	cin >> a;
	sort(a.begin(), a.end());
	cout << a;
}


#include <iostream>
#include <algorithm>

using namespace std;

char s[100000 + 1];

int main() {
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
}


#include <iostream>
#include <fstream>
#include <cstdlib>

#include <math.h>
#include<algorithm>
#include<string>
using namespace std;
long long n;
char s[100000 + 8];

int main()
{
	cin >> n;
	for (int i = 1; i < n+1; i++)
	{
		cin >> s[i];
	}
	string t;
	for (long long  i = 1; i < n+1; i++)
	{
		t = t + s[i];
	}
	sort(t.begin(), t.end());
	cout << t;

	//system("pause");
	return 0;

}


#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int n,mass[100];
char c;
string s;

int main(){
	//freopen("b.in","r",stdin);
	//freopen("b.out","w",stdout);

    cin >> n;

    getline(cin, s);

    for(int i=0; i<n; i++){

        cin >> c;
        mass[c-'a']++;
    }

    for(int i=0; i<26; i++){

        for(int j=0; j<mass[i]; j++){

            cout << (char) (i+'a');

        }

    }

	return 0;

}


#include<algorithm>
#include<fstream>
#include<iostream>
#include<iomanip>
#include<string>
#include<string.h>
#define forr(i,a,b) for(long i=a;i<=b;i++)
#define ford(i,a,b) for(long i=a;i>=b;i--)
#define ll long long
using namespace std;
const ll MaxN=2e5;
ll n,a[MaxN],f[MaxN][13],cs,ress;
string s;
void work()
{
    forr(i,0,n-1) a[i+1]=int(s[i]);
    sort(a+1,a+1+n);
    forr(i,1,n) cout<<char(a[i]);
}
ll check(string s)
{
    ll n,ress;
    n=s.length();
	ress=0;
	bool kt;
	forr(i,0,n-1)
        forr(j,i,n-1)
            {
                kt=true;
                forr(k,1,(j-i+1))
                    if (s[i+k-1]!=s[j-k+1]) kt=false;
                if (kt) ress++;
            }
    return ress;
}
void nhap()
{
    cin>>n;
    cin>>s;
}
int main()
{
	nhap();
    work();
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{int rec[26]={0},n;
char c;
scanf("%d",&n);scanf("%c",&c);
for(int i=0;i<n;i++)
{scanf("%c",&c);rec[c-'a']++;}
for(int i=0;i<26;i++)
	for(int j=0;j<rec[i];j++)
		printf("%c",i+'a');}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <iomanip>
#include <cctype>
#include <map>
#include <climits>
#include <memory.h>

using namespace std;

typedef long long LL;

int main() {
	ios::sync_with_stdio(false);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	string s;
	cin >> n;
	cin >> s;
	map<char, int> m;
	vector<pair<int, char>> v;
	for (int i = 0; i < n; ++i) {
		m[s[i]]++;
	}
	for (auto it = m.begin(); it != m.end(); ++it) {
		v.push_back(make_pair(it->second, it->first));
	}
	sort(v.rbegin(), v.rend());
	string ans;
	for (int i = 0; i < v.size(); i+=2) {
		if (i == v.size() - 1)
			break;
		int k = min(v[i].first, v[i + 1].first);
		for (int j = 0; j < k; ++j) {
			ans += v[i].second;
			ans += v[i + 1].second;
			v[i].first--;
			v[i+1].first--;
		}
	}
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].first; ++j) {
			ans += v[i].second;
		}
	}
	cout << ans;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <iomanip>
#include <cctype>
#include <map>
#include <climits>
#include <memory.h>

using namespace std;

typedef long long LL;

int main() {
	ios::sync_with_stdio(false);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	string s;
	cin >> n;
	cin >> s;
	map<char, int> m;
	vector<pair<int, char>> v;
	for (int i = 0; i < n; ++i) {
		m[s[i]]++;
	}
	for (auto it = m.begin(); it != m.end(); ++it) {
		v.push_back(make_pair(it->second, it->first));
	}
	sort(v.rbegin(), v.rend());
	vector<pair<int, char>> vv;
	for (int i = 0; i < v.size();++i){
		vv.push_back(v[i]);
		vv[i].first /= 2;
	}
	string ans;
	for (int az = 0; az < v[0].first; ++az) {
		for (int i = 0; i < v.size(); i++) {
			if (vv[i].first > 0) {
				ans += v[i].second;
				vv[i].first--;
				v[i].first-=2;
			}
		}
	}
	string ss = ans;
	reverse(ss.begin(), ss.end());
	for (int i = 0; i < v.size(); ++i) {
		if (v[i].first > 0)
		{
			ss += v[i].second;
			v[i].first--;
			break;
		}
	}
	ss += ans;
	for (int i = 0; i < v.size(); ++i) {
		for (int j = 0; j < v[i].first; ++j) {
			ss += v[i].second;
		}
	}
	cout << ss;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <iomanip>
#include <cctype>
#include <map>
#include <climits>
#include <memory.h>

using namespace std;

typedef long long LL;

int main() {
	ios::sync_with_stdio(false);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	string s;
	cin >> n;
	cin >> s;
	map<char, int> m;
	vector<pair<int, char>> v;
	for (int i = 0; i < n; ++i) {
		m[s[i]]++;
	}
	for (auto it = m.begin(); it != m.end(); ++it) {
		v.push_back(make_pair(it->second, it->first));
	}
	sort(v.rbegin(), v.rend());
	string ans;
	for (int i = 0; i < v.size(); i++) {
		int k = v[i].first / 2;
		for (int j = 0; j < k; ++j) {
			ans += v[i].second;
			v[i].first -= 2;
		}
	}
	string ss = ans;
	reverse(ss.begin(), ss.end());
	for (int i = 0; i < v.size(); ++i) {
		if (v[i].first > 0)
		{
			ss += v[i].second;
			v[i].first--;
			break;
		}
	}
	ss += ans;
	for (int i = 0; i < v.size(); ++i) {
		for (int j = 0; j < v[i].first;++j){
			ss += v[i].second;
		}
	}
	cout << ss;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <iomanip>
#include <cctype>
#include <map>
#include <climits>
#include <memory.h>

using namespace std;

typedef long long LL;

int main() {
	ios::sync_with_stdio(false);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	string s;
	cin >> n;
	cin >> s;
	map<char, int> m;
	vector<pair<int, char>> v;
	for (int i = 0; i < n; ++i) {
		m[s[i]]++;
	}
	for (auto it = m.begin(); it != m.end(); ++it) {
		v.push_back(make_pair(it->second, it->first));
	}
	sort(v.rbegin(), v.rend());
	string ans;
	for (int i = 0; i < v.size(); i+=2) {
		if (i == v.size() - 1) {
			int k = v[i].first/ 2;
			for (int j = 0; j < k; ++j) {
				ans += v[i].second;
				v[i].first -= 2;
			}
		}
		else {
			int k = min(v[i].first, v[i + 1].first) / 2;
			for (int j = 0; j < k; ++j) {
				ans += v[i + 1].second;
				ans += v[i].second;
				v[i].first -= 2;
				v[i + 1].first -= 2;
			}
		}
	}
	string ss = ans;
	reverse(ss.begin(), ss.end());
	for (int i = 0; i < v.size(); ++i) {
		if (v[i].first > 0)
		{
			ss += v[i].second;
			v[i].first--;
			break;
		}
	}
	ss += ans;
	for (int i = 0; i < v.size(); ++i) {
		for (int j = 0; j < v[i].first;++j){
			ss += v[i].second;
		}
	}
	cout << ss;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <iomanip>
#include <cctype>
#include <map>
#include <climits>
#include <memory.h>

using namespace std;

typedef long long LL;

int main() {
	ios::sync_with_stdio(false);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	string s;
	cin >> n;
	cin >> s;
	sort(s.begin(),s.end());
	cout<<s;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <iomanip>
#include <cctype>
#include <map>
#include <climits>
#include <memory.h>

using namespace std;

typedef long long LL;

int main() {
	ios::sync_with_stdio(false);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	string s;
	cin >> n;
	cin >> s;
	map<char, int> m;
	vector<pair<int, char>> v;
	for (int i = 0; i < n; ++i) {
		m[s[i]]++;
	}
	for (auto it = m.begin(); it != m.end(); ++it) {
		v.push_back(make_pair(it->second, it->first));
	}
	sort(v.rbegin(), v.rend());
	string ans;
	for (int i = 0; i < v.size(); i += 2) {
		int k = v[i].first / 2;
		for (int j = 0; j < k; ++j) {
			ans += v[i].second;
			v[i].first -= 2;
		}
	}
	string ss = ans;
	reverse(ss.begin(), ss.end());
	for (int i = 0; i < v.size(); ++i) {
		if (v[i].first > 0)
		{
			ans += v[i].second;
			v[i].first--;
			break;
		}
	}
	ans += ss;
	for (int i = 0; i < v.size(); ++i) {
		for (int j = 0; j < v[i].first;++j){
			ans += v[i].second;
		}
	}
	cout << ans;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <iomanip>
#include <cctype>
#include <map>
#include <climits>
#include <memory.h>

using namespace std;

typedef long long LL;

int main() {
	ios::sync_with_stdio(false);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	string s;
	cin >> n;
	cin >> s;
	map<char, int> m;
	vector<pair<int, char>> v;
	for (int i = 0; i < n; ++i) {
		m[s[i]]++;
	}
	for (auto it = m.begin(); it != m.end(); ++it) {
		v.push_back(make_pair(it->second, it->first));
	}
	sort(v.rbegin(), v.rend());
	string ans;
	for (int i = 0; i < v.size(); i+=2) {
		if (i == v.size() - 1)
			break;
		int k = min(v[i].first, v[i + 1].first);
		for (int j = 0; j < k; ++j) {
			ans += v[i].second;
			ans += v[i + 1].second;
			v[i].first--;
			v[i+1].first--;
		}
		if (v[i].first > 0) {
			ans += v[i].second;
			v[i].first--;
		}
		if (v[i+1].first > 0) {
			ans += v[i+1].second;
			v[i+1].first--;
		}
	}
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].first; ++j) {
			ans += v[i].second;
		}
	}
	cout << ans;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <iomanip>
#include <cctype>
#include <map>
#include <climits>
#include <memory.h>

using namespace std;

typedef long long LL;

int main() {
	ios::sync_with_stdio(false);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	string s;
	cin >> n;
	cin >> s;
	map<char, int> m;
	vector<pair<int, char>> v;
	for (int i = 0; i < n; ++i) {
		m[s[i]]++;
	}
	for (auto it = m.begin(); it != m.end(); ++it) {
		v.push_back({ it->second, it->first });
	}
	sort(v.rbegin(), v.rend());
	string ans;
	for (int i = 0; i < v.size(); i+=2) {
		if (i == v.size() - 1)
			break;
		int k = min(v[i].first, v[i + 1].first);
		for (int j = 0; j < k; ++j) {
			ans += v[i].second;
			ans += v[i + 1].second;
			v[i].first--;
			v[i+1].first--;
		}
	}
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].first; ++j) {
			ans += v[i].second;
		}
	}
	cout << ans;
	return 0;
}


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

int main() {
	int n;
	char ch[100010];
	while(cin >> n) {
		cin >> ch;
		sort(ch, ch +n);
		cout << ch << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>

using namespace std;

vector <char> v;
vector <int> k;

int main(){
	int n;
	char c;
	cin >> n;
	bool b;

	for(int i = 0; i < n; i ++){
		cin >> c;
		b = 0;
		for (int j = 0; j < v.size(); j ++){
			if (c == v[j]){
				b = 1;
				k[j] ++;
				break;
			}
		}
		if (!b){
			v.push_back (c);
			k.push_back (1);
		}
	}

	for (int i = 0; i < v.size(); i ++){
		for (int j = 0; j < k[i]; j ++)
			cout << v[i];
	}

	return 0;
}


#include <iostream>
using namespace std;

int ans[1005];

int main(int argc, char const *argv[])
{
	int n; cin>>n;
	for (int i=1; i<=n; i++)
	{
		char ch; cin>>ch;
		if (ch>='a' && ch<='z') ans[ch]++;
	}
	for (char i='a'; i<='z'; i++)
		for (int j=1; j<=ans[i]; j++) cout<<i;
	return 0;
}


#include <iostream>
using namespace std;

char ans[1005];

int main(int argc, char const *argv[])
{
	int n; cin>>n;
	for (int i=1; i<=n; i++)
	{
		char ch; cin>>ch;
		if (ch>='a' && ch<='z') ans[ch]++;
	}
	for (char i='a'; i<='z'; i++)
		for (int j=1; j<=ans[i]; j++) cout<<i;
	return 0;
}


#include <iostream>
using namespace std;

char ch[100005];

int main(int argc, char const *argv[])
{
	int n; cin>>n;
	for (int i=1; i<=n; i++) cin>>ch[i];
	sort(ch+1,ch+n+1);
	for (int i=1; i<=n; i++) cout<<ch[i];
	return 0;
}


#include <cstdio>

int main(int argc, char const *argv[])
{
    //freopen("C.txt", "r", stdin);
    int n;
    char a[100009];
    int count[256];
    scanf("%d", &n);
    scanf("%s", a);
    for (int i=0; i<n; i++)
    {
        count[a[i]] ++;
    }
    for(int i=0; i<256; i++)
    {
        while (count[i] > 0)
        {
            printf("%c", i);
            --count[i];
        }
    }
    printf("\n");
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long mypow(long long x){
    long long aa=1;
    long long tt=2;
    while(x){
        if(x&1)aa*=tt;
        tt*=tt;
        x/=2;
    }
    return aa;
}
char ch[100005];
int nums[54];
int main(){
int n;
cin>>n;
cin>>ch;
for(int i=0;i<n;i++){
    nums[ch[i]-'a']++;
    //cout << ch[i]-'a'<<endl;
}
for(int i=0;i<54;i++){
    if(nums[i]>1){
        while(nums[i]){
            printf("%c",'a'+i);
            nums[i]--;
        }
        break;
    }
}
for(int i=0;i<54;i++){
    if(nums[i]==1){
         while(nums[i]){
            printf("%c",'a'+i);
            nums[i]--;
        }
    }
}
for(int i=0;i<54;i++){
    if(nums[i]>1){
        while(nums[i]){
            printf("%c",'a'+i);
            nums[i]--;
        }
       // break;
    }
}
printf("\n");
/*cin>>n;
cin>>ch;
for(int i=0;i<n;i++){
    nums[ch[i]-'a']++;
}
for(int i=0;i<54;i++){
    while(nums[i]){
        printf("%c",'a'+i);
        nums[i]--;
    }
}*/
  /*  int num[100];
    int num2[100];
    char ch[100];
    char ch2[100];
   // int n;
    while(cin>>n){
    for(int i=0;i<n;i++){
        scanf("%d",&num[i]);
        num2[i]=num[i];
    }
    int maxx=0;
   // while(scanf("%s",ch)!=EOF){
      do{
        for(int i=0;i<n;i++){
            ch[i]=num[i]+'0';
            ch2[n-1-i]=ch[i];
        }

        ch[n]='\0';
        int len=strlen(ch);
        int sum=0;
        for(int i=2;i<=len;i++){
           // for(int j=0;j<len;j++){
                int f=1;
                for(int k=0;k<i/2;k++){
                    if(ch[k]!=ch[i-k-1]){
                        f=0;
                    }
                    }
            //    }
                if(f){sum++;}

        }
        for(int i=2;i<len;i++){
           // for(int j=0;j<len;j++){
                int f=1;
                for(int k=0;k<i/2;k++){
                    if(ch2[k]!=ch2[i-k-1]){
                        f=0;
                    }
                    }
            //    }
                if(f){sum++;}

        }
              //  cout << ch<<endl;
        maxx=max(maxx,sum);
       // cout <<ch<<"   "<<sum<<endl;
        }while(next_permutation(num,num+n));
      do{
        for(int i=0;i<n;i++){
            ch[i]=num[i]+'0';
            ch2[n-1-i]=ch[i];
        }

        ch[n]='\0';
        int len=strlen(ch);
        int sum=0;
        for(int i=2;i<=len;i++){
           // for(int j=0;j<len;j++){
                int f=1;
                for(int k=0;k<i/2;k++){
                    if(ch[k]!=ch[i-k-1]){
                        f=0;
                    }
                    }
            //    }
                if(f){sum++;}

        }
        for(int i=2;i<len;i++){
           // for(int j=0;j<len;j++){
                int f=1;
                for(int k=0;k<i/2;k++){
                    if(ch2[k]!=ch2[i-k-1]){
                        f=0;
                    }
                    }
            //    }
                if(f){sum++;}

        }
        if(sum==maxx)cout <<ch<<endl;
              //  cout << ch<<endl;
        //maxx=max(maxx,sum);
       // cout <<ch<<"   "<<sum<<endl;
        }while(next_permutation(num,num+n));
}   // }*/
    return 0;
}


#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cassert>
#include <stdio.h>
#include <string.h>
using namespace std;
typedef long long ll;
#pragma warning(disable:4996)
int main(){
	/*FILE *f;
	freopen_s(&f, "in.txt", "r+", stdin);
	freopen_s(&f, "out.txt", "w+", stdout);*/
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector <int> z(33, 0);
	for (int i = 0; i < s.length(); i++)
		z[s[i] - 'a']++;
	for (int i = 0; i < 26;i++)
	while (z[i]){ printf("%c", i + 'a'); z[i]--; }
	//cin >> s;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
//#include <stdio.h>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*/998244353;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	cout << s;
	gg;
}


#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
const int maxn=1e5+100;
int len;
char str[maxn];
int main()
{
    scanf("%d",&len);
    scanf("%s",str);
    sort(str,str+len);
    puts(str);
    return 0;
}


a = input()
b = ''.join(sorted(a))
print(b)


n = input()
a = input()
b = ''.join(sorted(a))
print(b)


n = int(input())
s = input()
s = sorted(s)
def check(st):
    ln = len(st)
    for i in range(ln>>1):
        if st[i] != st[ln-1-i]:
            return 0
    return 1
ans = 0
for i in range(n):
    for j in range(i, n):
        if check(s[i:j+1])==1:
            ans+=1
for i in range(n):
    print(s[i],end='')


n = int(input())
s = input()
s = sorted(s)
def check(st):
    ln = len(st)
    for i in range(ln>>1):
        if st[i] != st[ln-1-i]:
            return 0
    return 1
for i in range(n):
    print(s[i],end='')


if __name__ == "__main__":
    n = int(input())
    ss = input()
    fs = {}
    for s in ss:
        fs[s] = fs.get(s, 0) + 1
    result = ""
    for k,v in fs.items():
        result += k*v
    print( result )


if __name__ == "__main__":
    n = int(input())
    ss = input()
    fs = {}
    for s in ss:
        fs[s] = fs.get(s, 0) + 1
    result = ""
    for k,v in fs:
        result += k*v
    print( result )


n = int(input())
s = input()
print(''.join(sorted(s)))


lens = input()
print(''.join(sorted(input())))


n = int(input())
s = input()
a = []
for i in s:
  a.append(i)
a.sort()
print("".join(a))


n = int(input())
s = input()
s.sort()
print(s)


import sys
from collections import Counter
n=int(input())
s=sys.stdin.readline().strip()
d=Counter(s)
p=''
q=[]
l=0
for v in d:
    p=p+v*(d[v]//2)
    l=l+d[v]//2
    d[v]=d[v]%2
    if d[v]==1:
        q.append(v)
k=0
a=''
for idx,v in enumerate(q):
    if k<l:
        a=a+p[k]+v+p[k]
        k=k+1

a=a+p[k:]+p[k:][::-1]+''.join(q[k:])
print(a)


import sys
from collections import Counter
n=int(input())
s=sys.stdin.readline().strip()
d=Counter(s)
p=''
q=[]
l=0
for v in d:
    p=p+v*(d[v]//2)
    l=l+d[v]//2
    d[v]=d[v]%2
    if d[v]==1:
        q.append(v)
k=1
a=''
r=q[0:1]
for idx,v in enumerate(q[1:]):
    if k-1<l:
        a=a+p[k]+v+p[k]
        k=k+1
a=a+p[k:]+''.join(r)+p[k:][::-1]+''.join(q[k:])
print(a)


import sys
from collections import Counter
n=int(input())
s=sys.stdin.readline().strip()
d=Counter(s)
p=''
q=[]
l=0
for v in d:
    p=p+v*(d[v]//2)
    l=l+d[v]//2
    d[v]=d[v]%2
    if d[v]==1:
        q.append(v)
k=0
a=''
r=q[0:1]
for idx,v in enumerate(q[1:]):
    if k<l:
        a=a+p[k]+v+p[k]
        k=k+1
a=a+p[k:]+''.join(r)+p[k:][::-1]+''.join(q[k+1:])
print(a)


import sys
from collections import Counter
n=int(input())
s=sys.stdin.readline().strip()
v=sorted(s)
print(v)


import sys
from collections import Counter
n=int(input())
s=sys.stdin.readline().strip()
d=Counter(s)
p=''
q=''
for v in d:
    p=p+v*(d[v]//2)
    d[v]=d[v]%2
    if d[v]==1:
        q=q+v
a=p+q[0:1]+p[::-1]+q[1:]
print(a)


import sys
from collections import Counter
n=int(input())
s=sys.stdin.readline().strip()
v=sorted(s)
print(''.join(v))


n = int(input())
s = input()
d = dict()
for k in s:
    if k not in d:
        d[k] = 0
    d[k] += 1
# print(d)
odd = []
even = []
for k in d:
    if d[k] & 1:
        odd.append(k)
    else:
        even.append(k)
# print(odd)
# print(even)
odd = sorted(odd, key=lambda x: d[x])
even = sorted(even, key=lambda x: d[x])[::-1]
# print(d)
# print(odd)
# print(even)
rs = ""
for m in odd:
    ev = even.pop()
    cs = ev * (d[ev]//2) + m * (d[m]//2)
    rs = rs + cs + m + cs[::-1]
es = ""
for m in even:
    es = es + m * (d[m]//2)
rs = rs + es + es[::-1]
print(rs)


n = int(input())
s = input()
d = dict()
for k in s:
    if k not in d:
        d[k] = 0
    d[k] += 1
# print(d)
odd = []
even = []
for k in d:
    if d[k] & 1:
        odd.append(k)
    else:
        even.append(k)
# print(odd)
# print(even)
rs = ""
for m in odd:
    ev = even.pop()
    cs = ev * (d[ev]//2) + m * (d[m]//2)
    rs = rs + cs + m + cs[::-1]
es = ""
for m in even:
    es = es + m * (d[m]//2)
rs = rs + es + es[::-1]
print(rs)


n = int(input())
s = input()
print("".join(sorted(s)))


n = int(input())
s = input()
d = dict()
for k in s:
    if k not in d:
        d[k] = 0
    d[k] += 1
# print(d)
odd = []
even = []
for k in d:
    if d[k] & 1:
        odd.append(k)
    else:
        even.append(k)
# print(odd)
# print(even)
odd = sorted(odd, key=lambda x: d[x])
even = sorted(even, key=lambda x: d[x])[::-1]
print(d)
print(odd)
print(even)
rs = ""
for m in odd:
    ev = even.pop()
    cs = ev * (d[ev]//2) + m * (d[m]//2)
    rs = rs + cs + m + cs[::-1]
es = ""
for m in even:
    es = es + m * (d[m]//2)
rs = rs + es + es[::-1]
print(rs)


import sys
sys.stdin.readline()
st = sys.stdin.readline().strip()
l = list(st)
l.sort()
print("".join(l))


a=[0 for i in range(1000005)]
n=int(input())
s=input()
for i in range(n):
    a[int(ord(s[i])-ord('a'))]+=1
for i in range(26):
    while(a[i]):
        print(chr(i+ord('a')),end='')
        a[i]-=1


import math

def is_palindrome(string):
	up_to_not_including = math.ceil(len(string))
	for i in range(up_to_not_including):
		if string[i] != string[len(string) - 1 - i]:
			return False
	return True

def count(string):
	print(string)
	count = 0
	for i in range(0, len(string) + 1):
		for j in range(i + 1, len(string) + 1):
			if is_palindrome(string[i:j]):
				count +=1
	return count

def solve(string):
	frequencies = {}
	for char in string:
		frequencies[char] = frequencies.get(char, 0) + 1

	to_join = []
	for char, freq in frequencies.items():
		to_join.append(char * freq)
	return "".join(to_join)

n = int(input())
string = input()[:n]
solution = solve(string)
print(solution)


from sys import stdin,stdout
n = stdin.readline()
b = [(lambda s : sorted(s))(list(stdin.readline()))]
stdout.write(''.join(b[0]))


from sys import stdin,stdout
n = stdin.readline()
stdout.write(''.join((lambda s : sorted(s))(list(stdin.readline()))))


int(input())
a = input()
print(''.join(sorted(a)))


n = int(input())
s =sorted(input())
for i in s:
    print(i,end = '')


n = int(input())
s = input()
s.sort()
print(s)


#include <vector>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

typedef pair<int,double> pid;
bool pred(pid l,pid r){
	if(l.second==r.second){
		return l.first<r.first;
	}else{
		return l.second>r.second;
	}
}
int main(){
	int n,t[2],k;
	cin>>n>>t[0]>>t[1]>>k;
	vvi s(n,vi(2));
	REP(i,n){
		cin>>s[i][0]>>s[i][1];
	}
	vector<pid> p;
	REP(i,n){
		double better=0;
		REP(j,2){
			double val=s[i][j]*t[0]*((100-k)*0.01)+s[i][(j+1)%2]*t[1];
			better=max(better,val);
		}
		p.push_back(make_pair(i+1,better));
	}
	sort(ALL(p),pred);
	REP(i,p.size()){
		printf("%d %.2f\n",p[i].first,p[i].second);
	}
}


#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int num;
	int r;
	int a,b;
}p[1005];
float MAX(int x,int y)
{
	return x>y?x:y;
}
int cmp(node x,node y)
{
	if(x.r!=y.r)return x.r>y.r;
	else return x.num<y.num;
}
int main()
{
	int k,i,n,t1,t2;
	cin>>n>>t1>>t2>>k;
	k=100-k;
	for(i=1;i<=n;i++)
	{
		p[i].num=i;
		cin>>p[i].a>>p[i].b;
		p[i].r=MAX(p[i].a*t1*k+100*p[i].b*t2,p[i].b*t1*k+100*p[i].a*t2);
	}
	sort(p+1,p+n+1,cmp);
	for(i=1;i<=n;i++)
		printf("%d %.2f\n",(float)p[i].r/100.0);
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int num;
	double r;
	double a,b;
}p[1005];
float MAX(float x,float y)
{
	return x>y?x:y;
}
int cmp(node x,node y)
{
	if(x.r!=y.r)return x.r>y.r;
	else return x.num<y.num;
}
int main()
{
	int i,n;
	double k,t1,t2;
	cin>>n>>t1>>t2>>k;
	k=1-k/100;
	for(i=1;i<=n;i++)
	{
		p[i].num=i;
		cin>>p[i].a>>p[i].b;
		p[i].r=MAX(p[i].a*t1*k+p[i].b*t2,p[i].b*t1*k+p[i].a*t2);
	}
	sort(p+1,p+n+1,cmp);
	for(i=1;i<=n;i++)
		printf("%d %.2f\n",p[i].num,p[i].r);
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int num;
	int r;
	int a,b;
}p[1005];
float MAX(int x,int y)
{
	return x>y?x:y;
}
int cmp(node x,node y)
{
	if(x.r!=y.r)return x.r>y.r;
	else return x.num<y.num;
}
int main()
{
	int k,i,n,t1,t2;
	cin>>n>>t1>>t2>>k;
	k=100-k;
	for(i=1;i<=n;i++)
	{
		p[i].num=i;
		cin>>p[i].a>>p[i].b;
		p[i].r=MAX(p[i].a*t1*k+100*p[i].b*t2,p[i].b*t1*k+100*p[i].a*t2);
	}
	sort(p+1,p+n+1,cmp);
	for(i=1;i<=n;i++)
		printf("%d %.2f\n",p[i].num,(float)p[i].r/100.0);
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int num;
	int r;
	int a,b;
}p[1005];
float MAX(int x,int y)
{
	return x>y?x:y;
}
int cmp(node x,node y)
{
	if(x.r!=y.r)return x.r>y.r;
	else return x.num<y.num;
}
int main()
{
	int k,i,n,t1,t2;
	cin>>n>>t1>>t2>>k;
	k=100-k;
	for(i=1;i<=n;i++)
	{
		p[i].num=i;
		cin>>p[i].a>>p[i].b;
		p[i].r=MAX(p[i].a*t1*k+100*p[i].b*t2,p[i].b*t1*k+100*p[i].a*t2);
	}
	sort(p+1,p+n+1,cmp);
	for(i=1;i<=n;i++)
		printf("%d %d %.2f\n",(float)p[i].r/100.0);
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int num;
	float r;
	float a,b;
}p[1005];
float MAX(float x,float y)
{
	return x>y?x:y;
}
int cmp(node x,node y)
{
	if(x.r!=y.r)return x.r>y.r;
	else return x.num<y.num;
}
int main()
{
	int i,n;
	float k,t1,t2;
	cin>>n>>t1>>t2>>k;
	k=1-k/100;
	for(i=1;i<=n;i++)
	{
		p[i].num=i;
		cin>>p[i].a>>p[i].b;
		p[i].r=MAX(p[i].a*t1*k+p[i].b*t2,p[i].b*t1*k+p[i].a*t2);
	}
	sort(p+1,p+n+1,cmp);
	for(i=1;i<=n;i++)
		printf("%d %.2f\n",p[i].num,p[i].r);
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int num;
	int r;
	int a,b;
}p[1005];
float MAX(int x,int y)
{
	return x>y?x:y;
}
int cmp(node x,node y)
{
	if(x.r!=y.r)return x.r>y.r;
	else return x.num<y.num;
}
int main()
{
	int k,i,n,t1,t2;
	cin>>n>>t1>>t2>>k;
	k=100-k;
	for(i=1;i<=n;i++)
	{
		p[i].num=i;
		cin>>p[i].a>>p[i].b;
		p[i].r=MAX(p[i].a*t1*k+100*p[i].b*t2,p[i].b*t1*k+100*p[i].a*t2);
	}
	sort(p+1,p+n+1,cmp);
	for(i=1;i<=n;i++)
		printf("%d %d %.2f\n",p[i].num,p[i].r,(float)p[i].r/100.0);
	return 0;
}


#include <string.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
using namespace std;
struct speed{double s;int number;};
struct gnom{double a,b;};

int comp(const void *i, const void *j)
{
	speed a,b;
	a=*(speed*)i;
	b=*(speed*)j;
	if (a.s>b.s) return 0;
	else if (a.s==b.s && a.number<b.number) return 0;
	else return 1;
};
int main()
{
	/*FILE *fin=freopen("in.txt","r",stdin);
	FILE *out=freopen("out.txt","w",stdout);*/
	int t1,t2,n,k;
	gnom m[1001];
	speed speeds[1001];
	cin >> n >> t1 >> t2 >> k;
	for (int i=0;i<n;i++) cin >> m[i].a >> m[i].b;
	for (int i=0;i<n;i++)
	{
		if (m[i].a*t1-m[i].a*t1*k/100+m[i].b*t2>m[i].b*t1-m[i].b*t1*k/100+m[i].a*t2)
			speeds[i].s=m[i].a*t1-m[i].a*t1*k/100+m[i].b*t2;
		else speeds[i].s=m[i].b*t1-m[i].b*t1*k/100+m[i].a*t2;
		speeds[i].number=i+1;
	}

	qsort(speeds,n,sizeof(speed),comp);
	for (int i=0;i<n;i++)
		printf("%d %.2llf\n",speeds[i].number,speeds[i].s);

	return 0;
}


#include <string.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
using namespace std;
struct speed{double s;int number;};
struct gnom{double a,b;};

int comp(const void *i, const void *j)
{
	speed a,b;
	a=*(speed*)i;
	b=*(speed*)j;
	if (a.s>b.s) return -1;
	else if (a.s==b.s && a.number<b.number) return -1;
	return 1;
};
int main()
{
	/*FILE *fin=freopen("in.txt","r",stdin);
	FILE *out=freopen("out.txt","w",stdout);*/
	int t1,t2,n,k;
	gnom m[1001];
	speed speeds[1001];
	cin >> n >> t1 >> t2 >> k;
	for (int i=0;i<n;i++) cin >> m[i].a >> m[i].b;
	for (int i=0;i<n;i++)
	{
		if (m[i].a*t1-m[i].a*t1*k/100+m[i].b*t2>m[i].b*t1-m[i].b*t1*k/100+m[i].a*t2)
			speeds[i].s=m[i].a*t1-m[i].a*t1*k/100+m[i].b*t2;
		else speeds[i].s=m[i].b*t1-m[i].b*t1*k/100+m[i].a*t2;
		speeds[i].number=i+1;
	}

	qsort(speeds,n,sizeof(speed),comp);
	for (int i=0;i<n;i++)
		printf("%d %.2llf\n",speeds[i].number,speeds[i].s);

	return 0;
}


#include <string.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
using namespace std;
struct speed{double s;int number;};
struct gnom{double a,b;};

int comp(const void *i, const void *j)
{
	speed a,b;
	a=*(speed*)i;
	b=*(speed*)j;
	if (a.s>b.s) return 0;
	else if (a.s==b.s && a.number<b.number) return 0;
	else return 1;
};
int main()
{
	/*FILE *fin=freopen("in.txt","r",stdin);
	FILE *out=freopen("out.txt","w",stdout);*/
	int t1,t2,n,k;
	const double eps=0.001;
	gnom m[1001];
	speed speeds[1001];
	cin >> n >> t1 >> t2 >> k;
	for (int i=0;i<n;i++) cin >> m[i].a >> m[i].b;
	for (int i=0;i<n;i++)
	{
		if (m[i].a*t1-m[i].a*t1*k/100+m[i].b*t2>m[i].b*t1-m[i].b*t1*k/100+m[i].a*t2)
			speeds[i].s=m[i].a*t1-m[i].a*t1*k/100-eps+m[i].b*t2;
		else speeds[i].s=m[i].b*t1-m[i].b*t1*k/100-eps+m[i].a*t2;
		speeds[i].number=i+1;
	}

	qsort(speeds,n,sizeof(speed),comp);
	for (int i=0;i<n;i++)
		printf("%d %.2llf\n",speeds[i].number,speeds[i].s);

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <conio.h>
#include <utility>
#include <set>
#include <time.h>
#include <list>
#include <typeinfo>
#include <cstdio>
#include <numeric>
#include <limits>
#include <functional>
using namespace std;
#define X first
#define Y second
#define PI 3.1415926535897932384626433832795
#define PI2 PI * 2
#define sqr(x) ((x)*(x))
#define all(n) (n).begin(), (n).end()
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef pair<double, double> pdd;
typedef vector<pdd> vpdd;
typedef pair<float, float> pff;
const int MOD = (int)1e9 + 7;
typedef double real;

void load(int k = 1) {
	if (k == 1)	{
#ifndef ONLINE_JUDGE
		freopen("in", "r", stdin);
		freopen("out", "w", stdout);
#endif
	} else {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
}

const int N = (int)1e5 + 10;
const int M = 100;
int A[M][M];

typedef pair<int, int> pp;

bool MyFunc(pp p1, pp p2) {
	if (p1.second == p2.second) {
		return p1.first < p2.first;
	} else {
		return p1.second > p2.second;
	}
}

void solve() {
	int n;
	int t1, t2, k;
	cin >> n >> t1 >> t2 >> k;
	k = 100 - k;
	vector<pp> r;
	for (int i = 0; i < n; ++i) {
		float a, b;
		cin >> a >> b;
		float sum1 = a * t1 * k + b * t2 * 100;
		float sum2 = b * t1 * k + a * t2 * 100;
		int res = max(sum1, sum2);
		r.push_back(make_pair(i + 1, res));
	}
	sort(all(r), MyFunc);
	cout.precision(2);
	cout.setf(ios::fixed);
	for (int i = 0; i < r.size(); ++i) {
		printf("%d %d.%02d\n", r[i].X, r[i].Y / 100, r[i].Y % 100);
	}
}

void solve2() {

}

#define TIME_CHECK

int main() {
#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c1 = clock();
#endif
#endif

	load();
	solve();

#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c2 = clock();
	cout << endl << "time: " << (c2 - c1) / (CLOCKS_PER_SEC / 1000);
#endif
#endif
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <conio.h>
#include <utility>
#include <set>
#include <time.h>
#include <list>
#include <typeinfo>
#include <cstdio>
#include <numeric>
#include <limits>
#include <functional>
using namespace std;
#define X first
#define Y second
#define PI 3.1415926535897932384626433832795
#define PI2 PI * 2
#define sqr(x) ((x)*(x))
#define all(n) (n).begin(), (n).end()
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef pair<double, double> pdd;
typedef vector<pdd> vpdd;
typedef pair<float, float> pff;
const int MOD = (int)1e9 + 7;
typedef double real;

void load(int k = 1) {
	if (k == 1)	{
#ifndef ONLINE_JUDGE
		freopen("in", "r", stdin);
		freopen("out", "w", stdout);
#endif
	} else {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
}

const int N = (int)1e5 + 10;
const int M = 100;
int A[M][M];

typedef pair<int, float> pp;

bool MyFunc(pp p1, pp p2) {
	if (p1.second == p2.second) {
		return p1.first < p2.first;
	} else {
		return p1.second > p2.second;
	}
}

void solve() {
	int n;
	float t1, t2, k1;
	cin >> n >> t1 >> t2 >> k1;
	k1 = 100 - k1;
	float k = k1 / 100.0f;
	vector<pp> r;
	for (int i = 0; i < n; ++i) {
		float a, b;
		cin >> a >> b;
		float res = -1;
		float sum1 = a * t1 * k + b * t2;
		float sum2 = b * t1 * k + a * t2;
		res = max(sum1, sum2);
		r.push_back(make_pair(i + 1, res));
	}
	sort(all(r), MyFunc);
	cout.precision(2);
	cout.setf(ios::fixed);
	for (int i = 0; i < r.size(); ++i) {
		cout << r[i].X << " " << r[i].Y << endl;
	}
}

void solve2() {

}

#define TIME_CHECK

int main() {
#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c1 = clock();
#endif
#endif

	load();
	solve();

#ifndef ONLINE_JUDGE
#ifdef TIME_CHECK
	double c2 = clock();
	cout << endl << "time: " << (c2 - c1) / (CLOCKS_PER_SEC / 1000);
#endif
#endif
	return 0;
}