#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")
using namespace std;
int N;
int A[2000000], B[2000000];
vector <int> solve(vector <int> a)
{
  N = a.size();
  for(int i = 0; i < N; i++) A[i] = a[i];
  int last[26], cnt[26], cnt1[26];
  memset(last, -1, sizeof(last));
  memset(cnt, 0, sizeof(cnt));
  memset(cnt1, 0, sizeof(cnt1));
  vector <int> L, R, S;
  for(int i = 0; i < N; i++)
  {
    for(int j = 0; j < 26; j++)
    {
      if(A[i] ^ (1 << j)) continue;
      B[i] = j;
      cnt[j]++;
      last[j] = i;
      break;
    }
  }
  for(int i = 0; i < N; i++)
  {
    cnt1[B[i]]++;
    if((cnt[B[i]] & 1) && (i == last[B[i]])) S.push_back(i);
    else if(cnt1[B[i]] & 1) L.push_back(i);
    else R.push_back(i);
  }
  if(S.size())
  {
    ll sum = 0, half;
    for(int x : S) sum += A[x];
    half = (sum + 1) >> 1;
    int mx = A[S.back()];
    if(mx < half) exit(333);
    int n = S.size();
    for(int i = 0; i < ((n - 1) >> 1); i++) L.push_back(S[i]);
    L.push_back(S[n - 1]);
    for(int i = ((n - 1) >> 1); i < (n - 1); i++) R.push_back(S[i]);
  }
  for(int x : R) L.push_back(x);
  return L;
}