#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef map<ll,ll> mll;

typedef vector < pii > vpii;
typedef vector < pll > vpll;

typedef vector <string> vs;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef vector< vpii > vvpii;
typedef vector < vpll > vvpll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ms;

#define mem(a, b) memset(a, (b), sizeof(a))
#define ff first
#define ss second
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define po pop_back
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define endl "\n"
#define SZ(x) ((int)x.size())

//debug template
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second);
cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""),
                          __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

template <typename T>
void ckmin(T& a, const T b) {a = min(a, b);}

template <typename T>
void ckmax(T& a, const T b) {a = max(a, b);}

template <typename T>
void print(vector <T> v) {
    for (T i : v) cout << i << " ";
    cout << '\n';
}

template <typename T>
void print(vector <vector <T>>& v) {
    for (vector <T>& vv : v) {
        for (T& i : vv)
            cout << i << " ";
        cout << '\n';
    }
}

template <typename T>
void read(vector <T>& v) {for (T& i : v) cin >> i;}

template <typename T>
void read(T&& t) {cin >> t;}

template <typename T, typename... Args>
void read(T&& t, Args&&... args)
{
    cin >> t;
    read(forward<Args>(args)...);
}

template <typename T>
void print(T&& t) {cout << t << '\n';}

template <typename T, typename... Args>
void print(T&& t, Args&&... args)
{
    cout << t << " ";
    print(forward<Args>(args)...);
}

void FAST_IO(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".txt").c_str(), "w", stdout);
    }
}
ll  binpow(ll a,  ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
bool isprime(int n){
    if(n<=1){return false;}
    if(n<=3){return true;}
    if(n%2==0||n%3==0){return false;}
    for(int i=5;i*i<=n;i+=6){
        if(n%i==0||n%(i+2)==0){return false;}
    }
    return true;
}
void seive(ll n){
	vector<int> is_prime(n+1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i * i <= n; i++) {
	    if (is_prime[i]) {
	        for (int j = i * i; j <= n; j += i)
	            is_prime[j] = false;
	    }
	}
	// for(int i=2;i<=n;i++){
	// 	if(is_prime[i])
	// 		ans.pb(i);
	// }
}
map<ll,ll> primeFactors(ll n)
{
	map<ll,ll> m;
    while (n % 2 == 0)
    {
        m[2]++;
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            m[i]++;
            n = n/i;
        }
    }
    if (n > 2)
        m[n]++;
    return m;
}

multiset<ll> get_factors(ll n){
	multiset<ll> m;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			if(n/i == i){
				m.insert(i);
			}
			else{
				m.insert(i);
				m.insert(n/i);
			}
		}
	}
	return m;
}

const ld pie = 3.14159265358979323846;
const ll mod = 1000000007;
 //const ll mod = 998244353;
// ll mod;
const ll inf = 1e15;

bool check_palin(ll n){
	ll h = n;
	ll rev =0;
	while(n){
		rev = (rev*10)+ n%10;
		n/=10;
	}
	return (h==rev);
}
// n<=10 -- O(N!) O(N^7) O(N^6)
// n<20 -- O(2^N) o(N^5)
// n<=80 -- O(N^4)
// n<=400 -- O(N^3)
// n<=7500 -- O(N^2)
// n<=10^4 -- O(Nsqrt(N))
// n<=10^5 -- O(NlogN)
// n<=10^6 -- O(N)
// n<=10^18 -- O(logN) O(1)
ll  C(int n,int m)
{
	ll z=1;
	for(int i=0;i<m;i++){
		z = z* (n-i)/(i+1);
		print(z);
	}
	return z;
}

void solve(){
	ll n;
	cin>>n;
	vll v(n);
	for(auto &i: v)
		cin>>i;
	set<int> s;
	for(auto i: v)
		s.insert(i);
	ll ans;
	for(auto i: s){
		ll j =0; ans = 1e15;
		ll flag = 0;ll ele = i;ll a = 0;
		for(ll i=0;i<n;i++){
			ll j = i;
			while(j<n and v[j]!=ele){
				j++;
				flag = 1;
			}
			if(flag){
				a++;
				i = j-1;
				flag = 0;
			}
		}
		ans = min(ans,a);
	}
	print(ans);
}

int32_t main()
{
    FAST_IO();
	ll t;
	cin>>t;
	while(t--) solve();
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef map<ll,ll> mll;

typedef vector < pii > vpii;
typedef vector < pll > vpll;

typedef vector <string> vs;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef vector< vpii > vvpii;
typedef vector < vpll > vvpll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ms;

#define mem(a, b) memset(a, (b), sizeof(a))
#define ff first
#define ss second
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define po pop_back
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define endl "\n"
#define SZ(x) ((int)x.size())

//debug template
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second);
cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""),
                          __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

template <typename T>
void ckmin(T& a, const T b) {a = min(a, b);}

template <typename T>
void ckmax(T& a, const T b) {a = max(a, b);}

template <typename T>
void print(vector <T> v) {
    for (T i : v) cout << i << " ";
    cout << '\n';
}

template <typename T>
void print(vector <vector <T>>& v) {
    for (vector <T>& vv : v) {
        for (T& i : vv)
            cout << i << " ";
        cout << '\n';
    }
}

template <typename T>
void read(vector <T>& v) {for (T& i : v) cin >> i;}

template <typename T>
void read(T&& t) {cin >> t;}

template <typename T, typename... Args>
void read(T&& t, Args&&... args)
{
    cin >> t;
    read(forward<Args>(args)...);
}

template <typename T>
void print(T&& t) {cout << t << '\n';}

template <typename T, typename... Args>
void print(T&& t, Args&&... args)
{
    cout << t << " ";
    print(forward<Args>(args)...);
}

void FAST_IO(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".txt").c_str(), "w", stdout);
    }
}
ll  binpow(ll a,  ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
bool isprime(int n){
    if(n<=1){return false;}
    if(n<=3){return true;}
    if(n%2==0||n%3==0){return false;}
    for(int i=5;i*i<=n;i+=6){
        if(n%i==0||n%(i+2)==0){return false;}
    }
    return true;
}
void seive(ll n){
	vector<int> is_prime(n+1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i * i <= n; i++) {
	    if (is_prime[i]) {
	        for (int j = i * i; j <= n; j += i)
	            is_prime[j] = false;
	    }
	}
	// for(int i=2;i<=n;i++){
	// 	if(is_prime[i])
	// 		ans.pb(i);
	// }
}
map<ll,ll> primeFactors(ll n)
{
	map<ll,ll> m;
    while (n % 2 == 0)
    {
        m[2]++;
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            m[i]++;
            n = n/i;
        }
    }
    if (n > 2)
        m[n]++;
    return m;
}

multiset<ll> get_factors(ll n){
	multiset<ll> m;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			if(n/i == i){
				m.insert(i);
			}
			else{
				m.insert(i);
				m.insert(n/i);
			}
		}
	}
	return m;
}

const ld pie = 3.14159265358979323846;
const ll mod = 1000000007;
 //const ll mod = 998244353;
// ll mod;
const ll inf = 1e15;

bool check_palin(ll n){
	ll h = n;
	ll rev =0;
	while(n){
		rev = (rev*10)+ n%10;
		n/=10;
	}
	return (h==rev);
}
// n<=10 -- O(N!) O(N^7) O(N^6)
// n<20 -- O(2^N) o(N^5)
// n<=80 -- O(N^4)
// n<=400 -- O(N^3)
// n<=7500 -- O(N^2)
// n<=10^4 -- O(Nsqrt(N))
// n<=10^5 -- O(NlogN)
// n<=10^6 -- O(N)
// n<=10^18 -- O(logN) O(1)
ll  C(int n,int m)
{
	ll z=1;
	for(int i=0;i<m;i++){
		z = z* (n-i)/(i+1);
		print(z);
	}
	return z;
}

void solve(){
	ll n;
	cin>>n;
	vll v(n);
	for(auto &i: v)
		cin>>i;
	map<ll,vll> m;
	for(ll i=0;i<n;i++){
		m[v[i]].pb(i);
	}
	ll ans = 1e15;
	for(auto i: m){
		ll last =0;ll a = 0;
		for(auto j: i.ss){
			//cout<<j<<' ';
			if(j!=0 and a==0 and last==0){
				a++;
				last = j;
			}
			if(j-last-1>0){
				a++;
			}
			last = j;
		}
		if(last!=n-1)
			a++;
		//cout<<endl;
		ans = min(ans,a);
	}
	//cout<<endl;
	if(ans==0 and m.size()>1){
		print(1);
		return;
	}
	if(ans==1 and m.size()==1){
		print(0);
		return;
	}
	print(ans);
}

int32_t main()
{
    FAST_IO();
	ll t;
	cin>>t;
	while(t--) solve();
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	ll n; cin >> n;
	map<ll, ll> ma;
	ll j = 0;
	vector<ll> a;
	for(ll i=0, x, b; i<n; ++i) {
		cin >> x;
		if (i && x==a.back())
			continue;
		a.push_back(x);
	}
	for(ll i = 0; i < a.size(); ++i) {
		if(!i || i==j-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, i.second);
		//cout << i.first << ' ' << i.second << ' ';
	}
	sort(begin(a), end(a));
	if(a[0] == a.back()) ans = 0;
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	int n; cin >> n;
	map<int, int> ma;
	int a[n+5], j = 0;
	for(int i=0, x, b; i<n; ++i) {
		cin >> x;
		if (!i && x==a[i-1])
			continue;
		a[i-1] = x;
		++j;
	}
	for(int i = 0; i < j; ++i) {
		if(!i || i==j-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, (ll)i.second);
	}
	sort(a, a + j);
	if (a[0] == a[j-1]) ans = 0;
	//cout << j << ' ';
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	ll n; cin >> n;
	map<ll, ll> ma;
	ll a[n+5], j = 0;
	for(ll i=0, x, b; i<n; ++i) {
		cin >> x;
		if (i && x==a[i-1])
			continue;
		a[j] = x;
		++j;
	}
	for(ll i = 0; i < j; ++i) {
		if(!i || i==j-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, i.second);
		//cout << i.first << ' ' << i.second << ' ';
	}
	sort(a, a+j);
	if(a[0] == a[j-1]) ans = 0;
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	ll n; cin >> n;
	map<ll, ll> ma;
	ll a[n+5], j = 0;
	for(ll i=0, x, b; i<n; ++i) {
		cin >> x;
		if (!i && x==a[i-1])
			continue;
		a[j] = x;
		++j;
	}
	for(ll i = 0; i < j; ++i) {
		if(!i || i==j-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, i.second);
		//cout << i.first << ' ' << i.second << ' ';
	}
	sort(a, a+j);
	if(a[0] == a[j-1]) ans = 0;
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	int n; cin >> n;
	map<int, int> ma;
	int a[n+5], j = 0;
	for(int i=0, x, b; i<n; ++i) {
		cin >> x;
		if (i && x==a[i-1])
			continue;
		a[j] = x;
		++j;
	}
	int sa;
	for(int i = 0; i < j; ++i) {
		if(!i || i==j-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, i.second);
		//cout << i.first << ' ' << i.second << ' ';
	}
	//cout << j <<' ' ;
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	int n; cin >> n;
	map<int, int> ma;
	int a[n+5], j = 0;
	for(int i=0, x, b; i<n; ++i) {
		cin >> x;
		if (!i && x==a[i-1])
			continue;
		a[j] = x;
		++j;
	}
	for(int i = 0; i < j; ++i) {
		if(!i || i==j-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, (ll)i.second);
	}
	sort(a, a + j);
	if (a[0] == a[j-1]) ans = 0;
	//cout << j << ' ';
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	ll n; cin >> n;
	map<ll, ll> ma;
	ll j = 0;
	vector<ll> a;
	for(ll i=0, x, b; i<n; ++i) {
		cin >> x;
		if (i && x==a.back())
			continue;
		a.push_back(x);
	}
	for(ll i = 0; i < a.size(); ++i) {
		if(!i || i==j-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, i.second);
		//cout << i.first << ' ' << i.second << ' ';
	}
	sort(begin(a), end(a));
	if(a[0] == a[j-1]) ans = 0;
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	ll n; cin >> n;
	map<ll, ll> ma;
	ll j = 0;
	vector<ll> a;
	for(ll i=0, x, b; i<n; ++i) {
		cin >> x;
		if (i && x==a.back())
			continue;
		a.push_back(x);
	}
	for(ll i = 0; i < a.size(); ++i) {
		if(!i || i == a.size()-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, i.second);
		//cout << i.first << ' ' << i.second << ' ';
	}
	sort(begin(a), end(a));
	if(a[0] == a.back()) ans = 0;
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	int n; cin >> n;
	map<ll, ll> ma;
	ll a[n+5], j = 0;
	for(int i=0, x, b; i<n; ++i) {
		cin >> x;
		if (!i && x==a[i-1])
			continue;
		a[i-1] = x;
		++j;
	}
	for(int i = 0; i < j; ++i) {
		if(!i || i==j-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, (ll)i.second);
	}
	sort(a, a + j);
	if (a[0] == a[j-1]) ans = 0;
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	int n; cin >> n;
	map<ll, ll> ma;
	ll a[n+5], j = 0;
	for(ll i=0, x, b; i<n; ++i) {
		cin >> x;
		if (!i && x==a[i-1])
			continue;
		a[j] = x;
		++j;
	}
	for(int i = 0; i < j; ++i) {
		if(!i || i==j-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, i.second);
		//cout << i.first << ' ' << i.second << ' ';
	}
	sort(a, a+j);
	if(a[0] == a[j-1]) ans = 0;
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define dg(x) cout << x << '\n';
const int md = 111539786;

int sol() {
	int n; cin >> n;
	map<ll, ll> ma;
	ll a[n+5], j = 0;
	for(ll i=0, x, b; i<n; ++i) {
		cin >> x;
		if (!i && x==a[i-1])
			continue;
		a[j] = x;
		++j;
	}
	for(int i = 0; i < j; ++i) {
		if(!i || i==j-1) {
			if (ma[a[i]] == 0)
				ma[a[i]] = 1;
		}
		else {
			if (ma[a[i]] == 0)
				ma[a[i]] = 2;
			else ma[a[i]]++;
		}
	}
	ll ans = 1e18;
	for (auto i : ma) {
		ans = min(ans, i.second);
		//cout << i.first << ' ' << i.second << ' ';
	}
	//cout << j <<' ' ;
	cout << ans;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while(tc--) {
		sol();
		cout << '\n';
	}
}


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

void test() {
    int n; cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return;
    }

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

    vector<int> condensed;
    for (auto a:A){
        if (condensed.empty() || a != condensed.back()) {
            condensed.push_back(a);
        }
    }

    // take counts of every integer except the first and last
    unordered_map<int, int> counts;
    for (int i = 1; i < condensed.size() - 1; ++i) {
        counts[i]++;
    }
    // # of operations is the smallest count
    int res = INT_MAX;
    for (auto a:A) {
        res = min(res, counts[a]);
    }
    cout << res << endl;
}

int main() {
    int t; cin >> t;
    for (int i=0;i<t;++i) {
        test();
    }
}


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

void test() {
    int n; cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return;
    }

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

    vector<int> condensed;
    for (auto a:A){
        if (condensed.empty() || a != condensed.back()) {
            condensed.push_back(a);
        }
    }

    // take counts of every integer except the first and last
    unordered_map<int, int> counts;
    bool all_same = true;
    int first = condensed.front();
    for (int i = 1; i < condensed.size() - 1; ++i) {
        counts[A[i]]++;
        if (A[i] != A[0]) {
            all_same = false;
        }
    }
    // # of operations is the smallest count
    int res = INT_MAX;
    for (auto a:A) {
        res = min(res, counts[a]);
    }
    // if every element is the same then the answer is 0. otherwise, res+1
    if (all_same) {
        cout << 0 << endl;
    }

    cout << res+1 << endl;
}

int main() {
    int t; cin >> t;
    for (int i=0;i<t;++i) {
        test();
    }
}


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

void test() {
    int n; cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return;
    }

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

    vector<int> condensed;
    for (auto a:A){
        if (condensed.empty() || a != condensed.back()) {
            condensed.push_back(a);
        }
    }

    // take counts of every integer except the first and last
    unordered_map<int, int> counts;
    bool all_same = true;
    for (int i = 1; i < condensed.size() - 1; ++i) {
        counts[i]++;
    }
    // # of operations is the smallest count
    int res = INT_MAX;
    for (auto a:A) {
        res = min(res, counts[a]);
    }

    if (res == 0) {
        if (a.front() != a.back()) {
            ++res;
        }
    }
    cout << res+1 << endl;
}

int main() {
    int t; cin >> t;
    for (int i=0;i<t;++i) {
        test();
    }
}


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

void test() {
    int n; cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return;
    }

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

    vector<int> condensed;
    for (auto a:A){
        if (condensed.empty() || a != condensed.back()) {
            condensed.push_back(a);
        }
    }

    // take counts of every integer except the first and last
    unordered_map<int, int> counts;
    bool all_same = true;
    int first = condensed.front();
    for (auto c: condensed) {
        if (c != first) {
            all_same= false;
        }
        counts[c]++;
    }
    counts[condensed.front()]--;
    counts[condensed.back()]--;

    // # of operations is the smallest count, +1
    int res = INT_MAX;
    for (auto a:A) {
        res = min(res, counts[a]);
    }
    // if every element is the same then the answer is 0. otherwise, res+1
    if (all_same) {
        cout << 0 << endl;
        return;
    }

    cout << res+1 << endl;
}

int main() {
    int t; cin >> t;
    for (int i=0;i<t;++i) {
        test();
    }
}


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

void test() {
    int n; cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return;
    }

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

    vector<int> condensed;
    for (auto a:A){
        if (condensed.empty() || a != condensed.back()) {
            condensed.push_back(a);
        }
    }

    // take counts of every integer except the first and last
    unordered_map<int, int> counts;
    bool all_same = true;
    int first = condensed.front();
    for (auto c: condensed) {
        counts[c]++;
    }
    counts[c.front()]--;
    counts[c.back()]--;

    // # of operations is the smallest count, +1
    int res = INT_MAX;
    for (auto a:A) {
        res = min(res, counts[a]);
    }
    // if every element is the same then the answer is 0. otherwise, res+1
    if (all_same) {
        cout << 0 << endl;
        return;
    }

    cout << res+1 << endl;
}

int main() {
    int t; cin >> t;
    for (int i=0;i<t;++i) {
        test();
    }
}


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

void test() {
    int n; cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return;
    }

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

    vector<int> condensed;
    for (auto a:A){
        if (condensed.empty() || a != condensed.back()) {
            condensed.push_back(a);
        }
    }

    // take counts of every integer except the first and last
    unordered_map<int, int> counts;
    bool all_same = true;
    for (int i = 1; i < condensed.size() - 1; ++i) {
        counts[i]++;
    }
    // # of operations is the smallest count
    int res = INT_MAX;
    for (auto a:A) {
        res = min(res, counts[a]);
    }

    if (res == 0) {
        if (A.front() == A.back()) {
            --res;
        }
    }
    cout << res+1 << endl;
}

int main() {
    int t; cin >> t;
    for (int i=0;i<t;++i) {
        test();
    }
}


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

void test() {
    int n; cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return;
    }

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

    vector<int> condensed;
    for (auto a:A){
        if (condensed.empty() || a != condensed.last()) {
            condensed.push_back(a);
        }
    }

    // take counts of every integer except the first and last
    unordered_map<int, int> counts;
    for (int i = 1; i < condensed.size() - 1; ++i) {
        counts[i]++;
    }
    // # of operations is the smallest count
    int res = INT_MAX;
    for (auto a:A) {
        res = min(res, counts[a]);
    }
    cout << res << endl;
}

int main() {
    int t; cin >> t;
    for (int i=0;i<t;++i) {
        test();
    }
}


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

void test() {
    int n; cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return;
    }

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

    vector<int> condensed;
    for (auto a:A){
        if (condensed.empty() || a != condensed.back()) {
            condensed.push_back(a);
        }
    }

    // take counts of every integer except the first and last
    unordered_map<int, int> counts;
    bool all_same = true;
    int first = condensed.front();
    for (auto c: condensed) {
        counts[c]++;
    }
    counts[condensed.front()]--;
    counts[condensed.back()]--;

    // # of operations is the smallest count, +1
    int res = INT_MAX;
    for (auto a:A) {
        res = min(res, counts[a]);
    }
    // if every element is the same then the answer is 0. otherwise, res+1
    if (all_same) {
        cout << 0 << endl;
        return;
    }

    cout << res+1 << endl;
}

int main() {
    int t; cin >> t;
    for (int i=0;i<t;++i) {
        test();
    }
}


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

int main()
{
	int n,t,i,j,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		int cou[200050]={0},la[200050]={0};
		cin>>n;
		for(i=0;i<n;i++)
		{
			cin>>x;
			if(la[x]<i)
			{
				cou[x]++;
			}
			la[x]=i+1;
		}
		for(i=0;i<n;i++)
		{
			if(x!=i&&la[i]!=0)
				cou[i]++;
			if(cou[i]<Min&&la[i]!=0)
				Min=cou[i];
		}
		if(Min==INT_MAX)
			cout<<'0'<<endl;
		else
			cout<<Min<<endl;
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
int cou[200005]={0},gg[200005]={0};

int main()
{
	int n,t,i,x,j,la=0,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		cin>>n;
		int xmax=-1,xmin=3000000;
		cin>>x;
		la=x;
		gg[x]=1;
		for(i=1;i<n;i++)
		{
			scanf("%d",&x);
			if(la!=x)
			{
				cou[x]++;
			}
			gg[x]=1;
			la=x;
		}
		cou[x]--;
		for(i=1;i<=n;i++)
		{
			if(gg[i])
				Min=min(cou[i],Min);
		}
		if(Min==INT_MAX)
			printf("0\n");
		else
			printf("%d\n",Min+1);
		memset(cou,0,sizeof(cou));
		memset(gg,0,sizeof(gg));
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
int x[200005],cou[200005]={0},la[200005]={0};

int main()
{
	int n,t,i,j,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		cin>>n;
		for(i=0;i<n;i++)
		{
			cin>>x[i];
			if(la[x[i]]<i)
			{
				cou[x[i]]++;
			}
			la[x[i]]=i+1;
		}
		for(i=0;i<n;i++)
		{
			if(x[n-1]!=i&&la[i]!=0)
				cou[i]++;
			if(cou[i]<Min&&la[i]!=0)
				Min=cou[i];
		}
		if(Min==INT_MAX)
			cout<<'0'<<endl;
		else
			cout<<Min<<endl;
		memset(cou,0,sizeof(cou));
		memset(la,0,sizeof(la));
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
int cou[200005]={0};
bool gg[200005];

int main()
{
	int n,t,i,x,j,la=0,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		memset(gg,0,sizeof(gg));
		cin>>n;
		cin>>x;
		la=x;
		gg[x]=1;
		for(i=1;i<n;i++)
		{
			scanf("%d",&x);
			if(la!=x)
			{
				cou[x]++;
			}
			gg[x]=1;
			la=x;
		}
		cou[x]--;
		for(i=1;i<=n;i++)
		{
			if(gg[i])
				Min=min(cou[i],Min);
		}
			printf("%d\n",Min+1);
		memset(cou,0,sizeof(cou));
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！
int lx[200010];
bool sf[200010];
int main()
{
	int N;
	cin>>N;
	while(N--)
	{
		int n;
		mem(lx);
		mem(sf);
		cin>>n;
		int la,now;
		cin>>la;
		sf[la]=1;
		for(int i=1;i<n;i++)
		{
			scanf("%d",&now);
			sf[now]=1;
			if(la!=now)
			{
				lx[now]++;
			}
			la=now;
		}
		lx[la]-=1;
		int ans=1e6;
		for(int i=1;i<=n;i++)
		{
			//printf("lx[%d]=%d\n",i,lx[i]);//***
			if(sf[i])
			{
				ans=min(ans,lx[i]);
			}
		}
		printf("%d\n",ans+1);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int cou[200005]={0},la[200005]={0};;

int main()
{
	int n,t,i,x,j,Min=3000000;
	cin>>t;
	while(t--)
	{
		cin>>n;
		int xmax=-1,xmin=3000000;
		for(i=0;i<n;i++)
		{

			scanf("%d",&x);
			if(la[x]<i)
			{
				cou[x]++;
			}
			la[x]=i+1;
			xmax=max(xmax,x);
			xmin=min(xmin,x);
		}
		for(i=xmin;i<=xmax;i++)
		{
			if(x!=i&&la[i]!=0)
				cou[i]++;
			if(cou[i]<Min&&la[i]!=0)
				Min=cou[i];
		}
		if(Min==INT_MAX)
			cout<<'0'<<endl;
		else
			cout<<Min<<endl;
		memset(cou,0,sizeof(cou));
		memset(la,0,sizeof(la));
		Min=3000000;
	}
}


#include<bits/stdc++.h>
using namespace std;
int x[200005],cou[200005]={0},la[200005]={0};

int main()
{
	int n,t,i,j,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		cin>>n;
		for(i=0;i<n;i++)
		{
			cin>>x[i];
			if(la[x[i]]<i)
			{
				cou[x[i]]++;
			}
			la[x[i]]=i+1;
		}
		for(i=1;i<=n;i++)
		{
			if(x[n-1]!=i&&la[i]!=0)
				cou[i]++;
		}
		for(i=0;i<n;i++)
		{
			if(cou[i]<Min&&cou[i]!=0)
				Min=cou[i];
		}
		if(Min==INT_MAX)
			cout<<'0'<<endl;
		else
			cout<<Min<<endl;
		memset(cou,0,sizeof(cou));
		memset(la,0,sizeof(la));
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
int x,cou[2000050]={0},la[2000050]={0};;

int main()
{
	int n,t,i,j,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		cin>>n;
		for(i=0;i<n;i++)
		{
			cin>>x;
			if(la[x]<i)
			{
				cou[x]++;
			}
			la[x]=i+1;
		}
		for(i=0;i<n;i++)
		{
			if(x!=i&&la[i]!=0)
				cou[i]++;
			if(cou[i]<Min&&la[i]!=0)
				Min=cou[i];
		}
		if(Min==INT_MAX)
			cout<<'0'<<endl;
		else
			cout<<Min<<endl;
		memset(cou,0,sizeof(cou));
		memset(la,0,sizeof(la));
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
int x[200005];

int main()
{
	int n,t,i,j,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		int cou[200005]={0},la[200005]={0};
		cin>>n;
		for(i=0;i<n;i++)
		{
			cin>>x[i];
			if(la[x[i]]<i)
			{
				cou[x[i]]++;
			}
			la[x[i]]=i+1;
		}
		for(i=0;i<n;i++)
		{
			if(x[n-1]!=i&&la[i]!=0)
				cou[i]++;
			if(cou[i]<Min&&la[i]!=0)
				Min=cou[i];
		}
		if(Min==INT_MAX)
			cout<<'0'<<endl;
		else
			cout<<Min<<endl;
//		memset(cou,0,sizeof(cou));
//		memset(la,0,sizeof(la));
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
int cou[200005]={0},gg[200005]={0};

int main()
{
	int n,t,i,x,j,la=0,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		cin>>n;
		int xmax=-1,xmin=3000000;
		cin>>x;
		la=x;
		gg[x]=1;
		for(i=1;i<n;i++)
		{
			scanf("%d",&x);
			if(la!=x)
			{
				cou[x]++;
			}
			gg[x]=1;
			la=x;
			xmax=max(xmax,x);
			xmin=min(xmin,x);
		}
		cou[x]--;
		for(i=xmin;i<=xmax;i++)
		{
			if(cou[i]<Min&&gg[i])
				Min=cou[i];
		}
		if(Min==INT_MAX)
			cout<<'0'<<endl;
		else
			cout<<Min+1<<endl;
		memset(cou,0,sizeof(cou));
		memset(gg,0,sizeof(gg));
		Min=INT_MAX;
		la=0;
	}
}


#include<bits/stdc++.h>
using namespace std;
int x,cou[200005]={0},la[200005]={0};;

int main()
{
	int n,t,i,j,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		cin>>n;
		int xmax=-1,xmin=INT_MAX;
		for(i=0;i<n;i++)
		{
			cin>>x;
			if(la[x]<i)
			{
				cou[x]++;
			}
			la[x]=i+1;
			xmax=max(xmax,x);
			xmin=min(xmin,x);
		}
		for(i=xmin;i<=xmax;i++)
		{
			if(x!=i&&la[i]!=0)
				cou[i]++;
			if(cou[i]<Min&&la[i]!=0)
				Min=cou[i];
		}
		if(Min==INT_MAX)
			cout<<'0'<<endl;
		else
			cout<<Min<<endl;
		memset(cou,0,sizeof(cou));
		memset(la,0,sizeof(la));
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
int cou[200005]={0},gg[200005]={0};

int main()
{
	int n,t,i,x,j,la=0,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		cin>>n;
		cin>>x;
		la=x;
		gg[x]=1;
		for(i=1;i<n;i++)
		{
			scanf("%d",&x);
			if(la!=x)
			{
				cou[x]++;
			}
			gg[x]=1;
			la=x;
		}
		cou[x]--;
		for(i=1;i<=n;i++)
		{
			if(gg[i])
				Min=min(cou[i],Min);
		}
			printf("%d\n",Min+1);
		memset(cou,0,sizeof(cou));
		memset(gg,0,sizeof(gg));
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
int cou[200005]={0},gg[200005]={0};

int main()
{
	int n,t,i,x,j,la=0,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		cin>>n;
		int xmax=-1,xmin=3000000;
		cin>>x;
		la=x;
		gg[x]=1;
		for(i=1;i<n;i++)
		{
			scanf("%d",&x);
			if(la!=x)
			{
				cou[x]++;
				gg[x]=1;
			}
			la=x;
			xmax=max(xmax,x);
			xmin=min(xmin,x);
		}
		cou[x]--;
		for(i=xmin;i<=xmax;i++)
		{
			if(cou[i]<Min&&gg[i]!=0)
				Min=cou[i];
		}
		if(Min==INT_MAX)
			cout<<'0'<<endl;
		else
			cout<<Min+1<<endl;
		memset(cou,0,sizeof(cou));
		memset(gg,0,sizeof(gg));
		Min=INT_MAX;
		la=0;
	}
}


#include<bits/stdc++.h>
using namespace std;
int cou[200005]={0},gg[200005]={0};

int main()
{
	int n,t,i,x,j,la=0,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		cin>>n;
		int xmax=-1,xmin=3000000;
		cin>>x;
		la=x;
		gg[x]=1;
		for(i=1;i<n;i++)
		{
			scanf("%d",&x);
			if(la!=x)
			{
				cou[x]++;
			}
			gg[x]=1;
			la=x;
		}
		cou[x]--;
		for(i=1;i<=n;i++)
		{
			if(gg[i])
				Min=min(cou[i],Min);
		}
		if(Min==INT_MAX)
			cout<<'0'<<endl;
		else
			cout<<Min+1<<endl;
		memset(cou,0,sizeof(cou));
		memset(gg,0,sizeof(gg));
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
int cou[200005]={0},gg[200005]={0};

int main()
{
	int n,t,i,x,j,la=0,Min=INT_MAX;
	cin>>t;
	while(t--)
	{
		cin>>n;
		int xmax=-1,xmin=3000000;
		cin>>x;
		la=x;
		gg[x]=1;
		for(i=1;i<n;i++)
		{
			scanf("%d",&x);
			if(la!=x)
			{
				cou[x]++;
			}
			gg[x]=1;
			la=x;
		}
		cou[x]--;
		for(i=1;i<=n;i++)
		{
			if(gg[i])
				Min=min(cou[i],Min);
		}
		if(Min==INT_MAX)
			printf("0\n");
		else
			printf("%d",Min+1);
		memset(cou,0,sizeof(cou));
		memset(gg,0,sizeof(gg));
		Min=INT_MAX;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define lli long long int

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n, f=-1, k=0, g=0, ck, ck2, z=0;
        cin>>n;
        int ar[200000]={0};
        for(int i=0; i<n; i++)
        {
            int x;
            cin>>x;
            if(!g) ck=x, g=1;
            if(f!=x && i!=n-1)
            {
                ar[x]++;
                f=x;
                z++;
                //ck2=x;
            }
        }
        //cout<<ck<<" "<<ck2<<endl;
        //for(int i=0; i<n; i++) cout<<ar[i]<<" ";
        //cout<<endl;
        if(z==1 || n==1) cout<<0<<endl;
        else{
            int mn=1e9;
            int te=-1;
            for(int i=1; i<=z; i++)
            {
                if(mn>ar[i] && ar[i]!=0)
                {
                    mn=ar[i];
                    te=i;
                }
            }
            //cout<<mn<<" "<<te<<endl;
            if(te==ck) mn--;
           // if(te==ck2) mn--;
            cout<<mn+1<<endl;

        }

    }
}


#include <bits/stdc++.h>
using namespace std;
#define lli long long int

int main()
{

	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int ar[200000];
		deque<int>dq;
		for(int i=0; i<n; i++)
		{
			int x;
			cin>>x;
			dq.push_back(x);

		}

		int x=dq.front();
		dq.pop_front();
		int f=0;
		//cout<<dq.front()<<endl;
		while(!dq.empty() && x==dq.front())
		{
			if(!dq.empty()) dq.pop_front();
			f=1;
		}
		//cout<<x<<endl;
		if(!f) dq.push_front(x);
		if(dq.size()==1 && f)
		{
			cout<<1<<endl;
			break;
		}
		int ck;
		if(!dq.empty()) ck=dq.front();
		int ans=0;
		while(!dq.empty())
		{
			int x=0;

			while(!dq.empty() && ck==dq.front())
			{
				if(!dq.empty()) dq.pop_front();
			}

			while(!dq.empty() && dq.front()!=ck)
			{
				if(!dq.empty()) dq.pop_front();
				x++;
			}
			if(x) ans++;
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define lli long long int

int main()
{

	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int ar[200000];
		deque<int>dq;
		for(int i=0; i<n; i++)
		{
			int x;
			cin>>x;
			dq.push_back(x);

		}

		int f=0;
		int ck=dq.front();
		dq.pop_front();

		if(!dq.empty()) dq.pop_back();
		int ans=0;
		while(!dq.empty())
		{
			int x=0;
			int te=dq.front();
			if(!dq.empty()) dq.pop_front();
			while(!dq.empty() && dq.front()!=te)
			{
				if(!dq.empty()) dq.pop_front();
				x++;
			}
			if(x) ans++;
		}
		cout<<ans<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,ans;
int a[100001];
priority_queue<int>Q;
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),ans+=(a[i]-1)/m+1;
	printf("%d\n",(ans-1)/2+1);
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;
int n,k;
int main(){
	int ans=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		int w;scanf("%d",&w);
		ans+=(w-1)/k+1;
	}
	printf("%d\n",(ans+1)/2);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,ans;
int a[100001];
priority_queue<int>Q;
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),Q.push(a[i]);
	while(!Q.empty())
	{
		int u=Q.top();Q.pop();
		if(u>m)u-=m,Q.push(u);
		if(!Q.empty())
		{
			int v=Q.top();Q.pop();
			if(v>m)v-=m,Q.push(v);
		}
		ans++;
	}printf("%d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,ans;
int a[100001];
priority_queue<int>Q;
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),Q.push(a[i]);
	while(!Q.empty())
	{
		int u=Q.top();Q.pop();
		if(u>k)u-=k,Q.push(u);
		int v=Q.top();Q.pop();
		if(v>k)v-=k,Q.push(v);
		ans++;
	}printf("%d\n",ans);
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
int n,k;
int w[100005];
int ans=0,sum,cnt=0;
int main()
{
    int i,j,l;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
        sum=0;
        if(w[i]%k!=0)sum++;
        sum+=(w[i]/k);
        ans+=sum;
        }
    if(ans%2==1)cnt++;
    cnt+=(ans/2);
    printf("%d",cnt);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
typedef long long LL;
inline int read()
{
	int x=0;bool f=0;char c=getchar();
	for (;c<'0'||c>'9';c=getchar()) f=c=='-'?1:0;
	for (;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
	return f?-x:x;
}
int n,k,sum;

int main()
{
	n=read();k=read();
	for (int i=1;i<=n;i++) sum+=(read()-1)/k+1;
	printf("%d\n",(sum+1)/2);
	return 0;
}


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

using namespace std;

#define ll long long int
#define mod 1000000007
void check(ll a) { cout<<a<<endl; }
bool prime [1000001];
int sieve(int a){memset(prime,true,sizeof(prime));int p;int i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
//vector<ll> a
//vector<pair<ll,ll> > a
ll n,k;
ll w[10000];
ll ans=0;
int main(){
	//ifstream cin("testcase.txt");
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	//Code Here
	cin>>n>>k;
	ll i;
	for(i=0;i<n;++i)
		cin>>w[i];

	sort(w,w+n);
	i=0;
	while(i<n){
		if(w[i]<=k)
			{
				if(w[i+1]<=k){
				ans++;
				i=i+2;
				}
				else if(w[i+1]<=2*k){
				ans++;
				w[i+1]-=k;
				i=i+1;
				}
				else if(w[i+1]>2*k){
					ans++;
					i=i+1;
					w[i+1]-=k;
				}
			}
		else if(w[i]<=2*k){
			ans++;
			i=i+1;
		}
		else if(w[i]>2*k){
			ans++;
			w[i]-=k;
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

#define ll long long int
#define mod 1000000007
void check(ll a) { cout<<a<<endl; }
bool prime [1000001];
int sieve(int a){memset(prime,true,sizeof(prime));int p;int i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
//vector<ll> a
//vector<pair<ll,ll> > a
ll n,k;
ll w[10000];
ll ans=0;
int main(){
	//ifstream cin("testcase.txt");
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	//Code Here
	cin>>n>>k;
	ll i;
	for(i=0;i<n;++i){
		cin>>w[i];
		if(w[i]<=k)
			w[i]=1;
		else{
			ll temp1;
			temp1 = w[i]%k;
			if(temp1==0)
				w[i]=w[i]/k;
			else
				w[i]=(w[i]/k)+1;
		}
	}

	for(i=0;i<n;++i){
		ans = ans+w[i];
	}
	ans = (ans/2) + (ans%2);
	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

#define ll long long int
#define mod 1000000007
void check(ll a) { cout<<a<<endl; }
bool prime [1000001];
int sieve(int a){memset(prime,true,sizeof(prime));int p;int i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
//vector<ll> a
//vector<pair<ll,ll> > a
int main(){
	//ifstream cin("testcase.txt");
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	//Code Here
	ll n,k;
	ll w[n];
	ll ans=0;
	cin>>n>>k;
	ll i;
	for(i=0;i<n;++i){
		cin>>w[i];
		if(w[i]<=k)
			w[i]=1;
		else{
			ll temp1;
			temp1 = w[i]%k;
			if(temp1==0)
				w[i]=w[i]/k;
			else
				w[i]=(w[i]/k)+1;
		}
	}

	for(i=0;i<n;++i){
		ans = ans+w[i];
	}
	ans = (ans/2) + (ans%2);
	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

#define ll long long int
#define mod 1000000007
void check(ll a) { cout<<a<<endl; }
bool prime [1000001];
int sieve(int a){memset(prime,true,sizeof(prime));int p;int i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
//vector<ll> a
//vector<pair<ll,ll> > a
int main(){
	//ifstream cin("testcase.txt");
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	//Code Here
	ll n,k;
	ll ans=0;
	cin>>n>>k;
	ll w[n];
	ll i;
	for(i=0;i<n;++i){
		cin>>w[i];
		if(w[i]<=k)
			w[i]=1;
		else{
			ll temp1;
			temp1 = w[i]%k;
			if(temp1==0)
				w[i]=w[i]/k;
			else
				w[i]=(w[i]/k)+1;
		}
	}

	for(i=0;i<n;++i){
		ans = ans+w[i];
	}
	ans = (ans/2) + (ans%2);
	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

#define ll long long int
#define mod 1000000007
void check(ll a) { cout<<a<<endl; }
bool prime [1000001];
int sieve(int a){memset(prime,true,sizeof(prime));int p;int i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
//vector<ll> a
//vector<pair<ll,ll> > a
ll n,k;
ll w[10000];
ll ans=0;
int main(){
	//ifstream cin("testcase.txt");
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	//Code Here
	cin>>n>>k;
	ll i;
	for(i=0;i<n;++i){
		cin>>w[i];
		if(w[i]<=k)
			w[i]=1;
		else{
			ll temp1;
			temp1 = w[i]%k;
			if(temp1==0)
				w[i]=w[i]/k;
			else
				w[i]=(w[i]/k)+1;
		}
	}

	for(i=0;i<n;++i){
		ans = ans+w[i];
	}
	ans = (ans/2) + (ans%2);

/*	sort(w,w+n);
	i=0;
	while(i<n){
		if(w[i]<=k)
			{
				if(w[i+1]<=k){
				ans++;
				i=i+2;
				}
				else if(w[i+1]<=2*k){
				ans++;
				w[i+1]-=k;
				i=i+1;
				}
				else if(w[i+1]>2*k){
					ans++;
					i=i+1;
					w[i+1]-=k;
				}
			}
		else if(w[i]<=2*k){
			ans++;
			i=i+1;
		}
		else if(w[i]>2*k){
			ans++;
			w[i]-=k;
		}
	}
*/
	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

#define ll long long int
#define mod 1000000007
void check(ll a) { cout<<a<<endl; }
bool prime [1000001];
int sieve(int a){memset(prime,true,sizeof(prime));int p;int i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
//vector<ll> a
//vector<pair<ll,ll> > a
ll n,k;
ll w[100000];
ll ans=0;
int main(){
	//ifstream cin("testcase.txt");
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	//Code Here
	cin>>n>>k;
	ll i;
	for(i=0;i<n;++i)
		cin>>w[i];

	sort(w,w+n);
	i=0;
	while(i<n){
		if(w[i]<=k)
			{
				if(w[i+1]<=k){
				ans++;
				i=i+2;
				}
				else if(w[i+1]<=2*k){
				ans++;
				w[i+1]-=k;
				i=i+1;
				}
			}
		else if(w[i]<=2*k){
			ans++;
			i=i+1;
		}
		else if(w[i]>2*k){
			ans++;
			w[i]-=k;
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

#define ll long long int
#define mod 1000000007
void check(ll a) { cout<<a<<endl; }
bool prime [1000001];
int sieve(int a){memset(prime,true,sizeof(prime));int p;int i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
//vector<ll> a
//vector<pair<ll,ll> > a
ll n,k;
ll w[10000];
ll ans=0;
int main(){
	//ifstream cin("testcase.txt");
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	//Code Here
	cin>>n>>k;
	ll i;
	for(i=0;i<n;++i)
		cin>>w[i];

	sort(w,w+n);
	i=0;
	while(i<n){
		if(w[i]<=k)
			{
				if(w[i+1]<=k){
				ans++;
				i=i+2;
				}
				else if(w[i+1]<=2*k){
				ans++;
				w[i+1]-=k;
				i=i+1;
				}
			}
		else if(w[i]<=2*k){
			ans++;
			i=i+1;
		}
		else if(w[i]>2*k){
			ans++;
			w[i]-=k;
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

#define ll long long int
#define mod 1000000007
void check(ll a) { cout<<a<<endl; }
bool prime [1000001];
int sieve(int a){memset(prime,true,sizeof(prime));int p;int i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
//vector<ll> a
//vector<pair<ll,ll> > a
ll n,k;
ll w[10000];
ll ans=0;
int main(){
	ifstream cin("testcase.txt");
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	//Code Here
	cin>>n>>k;
	ll i;
	for(i=0;i<n;++i)
		cin>>w[i];

	sort(w,w+n);
	i=0;
	while(i<n){
		if(w[i]<=k)
			{
				if(w[i+1]<=k){
				ans++;
				i=i+2;
				}
				else if(w[i+1]<=2*k){
				ans++;
				w[i+1]-=k;
				i=i+1;
				}
			}
		else if(w[i]<=2*k){
			ans++;
			i=i+1;
		}
		else if(w[i]>2*k){
			ans++;
			w[i]-=k;
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

typedef long ll;
typedef vector<long> v;
typedef vector<v> vv;
typedef pair<long, long> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<ii> sii;
typedef queue<long> q;

#define FOR(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,k,i;
	cin>>n>>k;

	ll p[n];

	FOR(i,n) cin>>p[i];

	ll total = 0;

	FOR(i,n){
		total += ceil(float(p[i])/k);
	}

	cout<<ceil(float(total)/2);

	return 0;
}


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

typedef int64_t ll;
typedef vector<long> v;
typedef vector<v> vv;
typedef pair<long, long> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<ii> sii;
typedef queue<long> q;

#define FOR(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,k,i;
	cin>>n>>k;

	ll p[n];

	FOR(i,n) cin>>p[i];

	ll total = 0;

	FOR(i,n){
		total += ll(ceil(float(p[i])/k));
	}

	cout<<ll(ceil(float(total)/2));

	return 0;
}


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

typedef int64_t ll;
typedef vector<long> v;
typedef vector<v> vv;
typedef pair<long, long> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<ii> sii;
typedef queue<long> q;

#define FOR(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,k,i;
	cin>>n>>k;

	ll p[n];

	FOR(i,n) cin>>p[i];

	ll total = 0;

	FOR(i,n){
		total += ceil(float(p[i])/k);
	}

	cout<<long(ceil(float(total)/2));

	return 0;
}


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

typedef long long ll;
typedef vector<long> v;
typedef vector<v> vv;
typedef pair<long, long> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<ii> sii;
typedef queue<long> q;

#define FOR(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,k,i;
	cin>>n>>k;

	ll p[n];

	FOR(i,n) cin>>p[i];

	ll total = 0;

	FOR(i,n){
		total += ceil(float(p[i])/k);
	}

	cout<<ceil(float(total)/2);

	return 0;
}


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

typedef int64_t ll;
typedef vector<long> v;
typedef vector<v> vv;
typedef pair<long, long> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<ii> sii;
typedef queue<long> q;

#define FOR(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,k,i;
	cin>>n>>k;

	ll p[n];

	FOR(i,n) cin>>p[i];

	ll total = 0;

	FOR(i,n){
		total += ceil(float(p[i])/k);
	}

	cout<<ll(ceil(float(total)/2));

	return 0;
}


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

typedef long ll;
typedef vector<long> v;
typedef vector<v> vv;
typedef pair<long, long> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<ii> sii;
typedef queue<long> q;

#define FOR(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ll n,k,i;
	cin>>n>>k;

	ll p[n];

	FOR(i,n) cin>>p[i];

	ll total = 0;

	FOR(i,n){
		total += ceil(float(p[i])/k);
	}

	cout<<ceil(float(total)/2);

	return 0;
}


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

typedef int64_t ll;
typedef vector<long> v;
typedef vector<v> vv;
typedef pair<long, long> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<ii> sii;
typedef queue<long> q;

#define FOR(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,k,i;
	cin>>n>>k;

	ll p[n];

	FOR(i,n) cin>>p[i];

	ll total = 0;

	FOR(i,n){
		total += p[i]/k;
		if(p[i]%k)
			total++;
	}

	ll ans = total/2;

	if(total%2)
		ans++;

	cout<<ans;

	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <utility>
#include <sstream>
using namespace std;
using namespace std;
typedef long long ll;
int main(){
	ll k;
      ll n;
      scanf("%I64d%I64d",n,k);
	ll NUM[100100];
	for(int i=1;i<=n;i++){
		scanf("%I64d",&NUM[i]);
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
        ans=ans+(NUM[i]+k-1)/k;
	}
      ans=(ans+1)/2;
      printf("%I64d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll k;
      ll n;
      scanf("%I64d%I64d",&n,&k);
	ll NUM[100100];
	for(int i=1;i<=n;i++){
		scanf("%I64d",&NUM[i]);
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
        ans=ans+(NUM[i]+k-1)/k;
	}
      ans=(ans+1)/2;
      printf("%I64d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll k;
      ll n;
	cin>>n;
	cin>>k;
	ll NUM[10010];
	for(int i=0;i<n;i++){
		cin>>NUM[i];
	}
	ll ans=0;
	for(int i=0;i<n;i++){
        ans=ans+(NUM[i]+k-1)/k;
	}
	cout<<(ans+1)/2<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll k;
      ll n;
      scanf("%I64d%I64d",n,k);
	ll NUM[100100];
	for(int i=1;i<=n;i++){
		scanf("%I64d",&NUM[i]);
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
        ans=ans+(NUM[i]+k-1)/k;
	}
      ans=(ans+1)/2;
      printf("%I64d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	long long k;
      long long n;
	cin>>n;
	cin>>k;
	ll* NUM=new ll[n];
	for(int i=0;i<n;i++){
		cin>>NUM[i];
	}
	float time=0;
	long long count=0;
	for(int i=0;i<n;i++){
       count=NUM[i]/k;
       if(NUM[i]%k!=0){
            count++;
       }
       time+=count;
	}
	cout<<ceil(time/2.0)<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll k;
      ll n;
      scanf("%I64d%I64d",n,k);
	ll NUM[100100];
	for(int i=0;i<n;i++){
		scanf("%I64d",&NUM[i]);
	}
	ll ans=0;
	for(int i=0;i<n;i++){
        ans=ans+(NUM[i]+k-1)/k;
	}
      ans=(ans+1)/2;
      printf("%I64d\n",ans);
	return 0;
}


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

const int  N = 1005,
            INF = 1e9;

long long sum, n, k, x, c;

int main()
{
        cin>>n>>k;

        for (int i=1; i<=n; ++i){
            cin>>x;
            if (x%k>0) c++;
            sum+=x/k;
        }
        int ans=(c+1)/2;
        ans+=(sum+1)/2;
        cout<<sum;

}


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

const int  N = 1005,
            INF = 1e9;

long long ans, sum, n, k, x, c;

int main()
{
        cin>>n>>k;

        for (int i=1; i<=n; ++i){
            cin>>x;
            if (x%k>0) c++;
            sum+=x/k;
        }
        if (c%2!=0&&sum%2!=0) c++; else c++, sum++;
        ans=c/2;
        ans+=sum/2;
        cout<<ans;

}


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

const int  N = 1005,
            INF = 1e9;

long long ans, sum=1, n, k, x, c=1;

int main()
{
        cin>>n>>k;

        for (int i=1; i<=n; ++i){
            cin>>x;
            if (x%k>0) c++;
            sum+=x/k;
        }
        ans=c/2;
        ans+=sum/2;
        cout<<ans;

}


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

const int  N = 1005,
            INF = 1e9;

int sum, n, k, x, c;

int main()
{
        cin>>n>>k;

        for (int i=1; i<=n; ++i){
            cin>>x;
            if (x%k>0) c++;
            sum+=x/k;
        }
        int ans=(c+1)/2;
        ans+=(sum+1)/2;
        cout<<ans;

}


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

const int  N = 1005,
            INF = 1e9;

long long sum, n, k, x, c;

int main()
{
        cin>>n>>k;

        for (int i=1; i<=n; ++i){
            cin>>x;
            if (x%k>0) c++;
            sum+=x/k;
        }
        int ans=(c+1)/2;
        ans+=(sum+1)/2;
        cout<<ans;

}


#include<iostream>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
int main () {
  long long n, k, sum=0;
  cin>>n>>k;
  long long* a=(long long*)calloc(n, sizeof(long long));
  for(long long i=0; i<n; i++)
    cin>>a[i];
  double days=0;
  for(long long i=0; i<n; i++) {
    sum+=ceil((float)a[i]/k);
  }
  cout<<ceil((float)sum/2);
  return 0;
}


#include<iostream>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
bool comp(const int a, const int b)
{
    return a > b;
}
int main () {
  long long n, k;
  cin>>n>>k;
  long long* a=(long long*)calloc(n, sizeof(long long));
  for(long long i=0; i<n; i++)
    cin>>a[i];
  long long kolvo_del4=0;
  double days=0;
  for(long long i=0; i<n; i++) {
    while(a[i]>=k) {
      a[i]-=k;
      days+=0.5;
    }
  }
  sort(a, a + n, comp);
  long long ch_not0=0;
  for(long long i=0; i<n; i++) {
    if(a[i]!=0) ch_not0++;
  }
  cout<<ceil((ch_not0/2+days));

  return 0;
}


#include<iostream>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
int main () {
  long long n, k, sum=0;
  cin>>n>>k;
  long long* a=(long long*)calloc(n, sizeof(long long));
  for(long long i=0; i<n; i++)
    cin>>a[i];
  for(long long i=0; i<n; i++) {
    if(a[i]%k==0) sum+=a[i]/k;
    else sum+=a[i]/k+1;
  }
  if(sum%2==0) cout<<sum/2;
  else cout<<sum/2+1;

  return 0;
}


#include<iostream>
#include<stdlib.h>
using namespace std;
void print(int n, int* a) {
  cout<<"------------"<<endl;
  for(int i=0; i<n; i++)
    cout<<a[i]<<" ";
  cout<<endl<<"------------"<<endl;
}
int main () {
  int n, k;
  cin>>n>>k;
  int* a=(int*)calloc(n, sizeof(int));
  for(int i=0; i<n; i++)
    cin>>a[i];
  int kolvo_del4=0;
  float days=0;
  for(int i=0; i<n; i++) {
    while(a[i]>=k) {
      a[i]-=k;
      days+=0.5;
    }
  }
  for(int i=0; i<n-1; i++)
    for(int j=0; j<n-i-1; j++)
      if(a[j]<a[j+1]) {
        int d=a[j];
        a[j]=a[j+1];
        a[j+1]=d;
      }
  int ch_not0=0;
  for(int i=0; i<n; i++) {
    if(a[i]!=0) ch_not0++;
  }
  cout<<int(ch_not0/2+days)+1;

  return 0;
}


#include<iostream>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
int main () {
  long long n, k;
  cin>>n>>k;
  long long* a=(long long*)calloc(n, sizeof(long long));
  for(long long i=0; i<n; i++)
    cin>>a[i];
  long long kolvo_del4=0;
  double days=0;
  for(long long i=0; i<n; i++) {
    while(a[i]>=k) {
      a[i]-=k;
      days+=0.5;
    }
  }
  long long ch_not0=0;
  for(long long i=0; i<n; i++) {
    if(a[i]!=0) ch_not0++;
  }
  if(ch_not0==1) ch_not0=2;
  cout<<ceil((ch_not0/2+days));

  return 0;
}


#include<iostream>
#include<stdlib.h>
using namespace std;
int main () {
  long long n, k;
  cin>>n>>k;
  long long* a=(long long*)calloc(n, sizeof(long long));
  for(long long i=0; i<n; i++)
    cin>>a[i];
  long long kolvo_del4=0;
  double days=0;
  for(long long i=0; i<n; i++) {
    while(a[i]>=k) {
      a[i]-=k;
      days+=0.5;
    }
  }
  for(long long i=0; i<n-1; i++)
    for(long long j=0; j<n-i-1; j++)
      if(a[j]<a[j+1]) {
        long long d=a[j];
        a[j]=a[j+1];
        a[j+1]=d;
      }
  long long ch_not0=0;
  for(long long i=0; i<n; i++) {
    if(a[i]!=0) ch_not0++;
  }
  cout<<((long long)(ch_not0/2+days))+1;

  return 0;
}


#include<iostream>
using namespace std;
void print(int n, int* a) {
  cout<<"------------"<<endl;
  for(int i=0; i<n; i++)
    cout<<a[i]<<" ";
  cout<<endl<<"------------"<<endl;
}
int main () {
  int n, k;
  cin>>n>>k;
  int* a=(int*)calloc(n, sizeof(int));
  for(int i=0; i<n; i++)
    cin>>a[i];
  int kolvo_del4=0;
  float days=0;
  for(int i=0; i<n; i++) {
    while(a[i]>=k) {
      a[i]-=k;
      days+=0.5;
    }
  }
  for(int i=0; i<n-1; i++)
    for(int j=0; j<n-i-1; j++)
      if(a[j]<a[j+1]) {
        int d=a[j];
        a[j]=a[j+1];
        a[j+1]=d;
      }
  int ch_not0=0;
  for(int i=0; i<n; i++) {
    if(a[i]!=0) ch_not0++;
  }
  cout<<int(ch_not0/2+days)+1;

  return 0;
}


#include<iostream>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
bool comp(const int a, const int b)
{
    return a > b;
}
int main () {
  long long n, k;
  cin>>n>>k;
  long long* a=(long long*)calloc(n, sizeof(long long));
  for(long long i=0; i<n; i++)
    cin>>a[i];
  long long kolvo_del4=0;
  double days=0;
  for(long long i=0; i<n; i++) {
    while(a[i]>=k) {
      a[i]-=k;
      days+=0.5;
    }
  }
  sort(a, a + n, comp);
  long long ch_not0=0;
  for(long long i=0; i<n; i++) {
    if(a[i]!=0) ch_not0++;
  }
  cout<<((long long)(ch_not0/2+days))+1;

  return 0;
}


#include<iostream>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
int main () {
  long long n, k, sum=0;
  cin>>n>>k;
  long long* a=(long long*)calloc(n, sizeof(long long));
  for(long long i=0; i<n; i++)
    cin>>a[i];
  for(long long i=0; i<n; i++) {
    sum+=ceil((double)a[i]/k);
  }
  cout<<ceil((double)sum/2);
  return 0;
}


#include<iostream>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
bool comp(const int a, const int b)
{
    return a > b;
}
int main () {
  long long n, k;
  cin>>n>>k;
  long long* a=(long long*)calloc(n, sizeof(long long));
  for(long long i=0; i<n; i++)
    cin>>a[i];
  long long kolvo_del4=0;
  double days=0;
  for(long long i=0; i<n; i++) {
    while(a[i]>=k) {
      a[i]-=k;
      days+=0.5;
    }
  }
  sort(a, a + n, comp);
  long long ch_not0=0;
  for(long long i=0; i<n; i++) {
    if(a[i]!=0) ch_not0++;
  }
  cout<<ceil((long long)(ch_not0/2+days));

  return 0;
}


#include<iostream>
#include<stdlib.h>
using namespace std;
int main () {
  long long n, k;
  cin>>n>>k;
  long long* a=(long long*)calloc(n, sizeof(long long));
  for(long long i=0; i<n; i++)
    cin>>a[i];
  long long kolvo_del4=0;
  double days=0;
  for(long long i=0; i<n; i++) {
    while(a[i]>=k) {
      a[i]-=k;
      days+=0.5;
    }
  }
  for(long long i=0; i<n-1; i++)
    for(long long j=0; j<n-i-1; j++)
      if(a[j]<a[j+1]) {
        long long d=a[j];
        a[j]=a[j+1];
        a[j+1]=d;
      }
  long long ch_not0=0;
  for(long long i=0; i<n; i++) {
    if(a[i]!=0) ch_not0++;
  }
  cout<<(long long(ch_not0/2+days))+1;

  return 0;
}


#include<iostream>
#include<stdlib.h>
using namespace std;
int main () {
  long long n, k;
  cin>>n>>k;
  long long* a=(long long*)calloc(n, sizeof(long long));
  for(long long i=0; i<n; i++)
    cin>>a[i];
  long long kolvo_del4=0;
  double days=0;
  for(long long i=0; i<n; i++) {
    while(a[i]>=k) {
      a[i]-=k;
      days+=0.5;
    }
  }
  for(long long i=0; i<n-1; i++)
    for(long long j=0; j<n-i-1; j++)
      if(a[j]<a[j+1]) {
        long long d=a[j];
        a[j]=a[j+1];
        a[j+1]=d;
      }
  long long ch_not0=0;
  for(long long i=0; i<n; i++) {
    if(a[i]!=0) ch_not0++;
  }
  cout<<long long(ch_not0/2+days)+1;

  return 0;
}


	#include<bits/stdc++.h>

	#define MAX 10000

	using namespace std;

	int main(){

		int w[MAX];
		int k, n, bolsos=0;
		cin>>n>>k;

		for(int i=0; i<n; i++){
			cin>>w[i];
			while(w[i]>0){
				w[i]-=k;
				bolsos++;
	//			cout<<"i= "<<i<<endl<<"bolsos= "<<bolsos<<endl;
			}
		}
		if(bolsos%2 == 0)
			cout<<bolsos/2;
		else
			cout<<bolsos/2+1;
		cout<<endl;

		return 0;
	}

/*
	FOR STR.LEN > 10, STR = "s[0]{int(n-2)}s[n-1]"
	sort(a, a+as);
	sort(b, b+bs);

*/


	#include<bits/stdc++.h>

	#define MAX 10000

	using namespace std;

	int main(){

		long int w[MAX];
		int k, n, bolsos=0;
		cin>>n>>k;

		for(int i=0; i<n; i++){
			cin>>w[i];
			while(w[i]>0){			/////
				w[i]-=k;
				bolsos++;
	//			cout<<"i= "<<i<<endl<<"bolsos= "<<bolsos<<endl;
			}
		}
		if(bolsos%2 == 0)
			cout<<bolsos/2;
		else
			cout<<bolsos/2+1;
		cout<<endl;

		return 0;
	}

/*
	FOR STR.LEN > 10, STR = "s[0]{int(n-2)}s[n-1]"
	sort(a, a+as);
	sort(b, b+bs);

*/


	#include<bits/stdc++.h>

	#define MAX 10000

	using namespace std;

	int main(){

		int w[MAX];
		long int k, n, bolsos=0;
		cin>>n>>k;

		for(int i=0; i<n; i++){
			cin>>w[i];
			while(w[i]>0){			/////
				w[i]-=k;
				bolsos++;
	//			cout<<"i= "<<i<<endl<<"bolsos= "<<bolsos<<endl;
			}
		}
		if(bolsos%2 == 0)
			cout<<bolsos/2;
		else
			cout<<bolsos/2+1;
		cout<<endl;

		return 0;
	}

/*
	FOR STR.LEN > 10, STR = "s[0]{int(n-2)}s[n-1]"
	sort(a, a+as);
	sort(b, b+bs);

*/


	#include<bits/stdc++.h>

	#define MAX 10000

	using namespace std;

	int main(){

		int w[MAX];
		int k, n, bolsos=0;
		cin>>n>>k;

		for(int i=0; i<n; i++){
			cin>>w[i];
			if(w[i]%k != 0 || w[i] < k)
				bolsos+= 1;
			bolsos+=w[i]/k;
		}
		if(bolsos%2 == 0)
			cout<<bolsos/2;
		else
			cout<<bolsos/2+1;
		cout<<endl;

		return 0;
	}

/*
	FOR STR.LEN > 10, STR = "s[0]{int(n-2)}s[n-1]"
	sort(a, a+as);
	sort(b, b+bs);

*/


	#include<bits/stdc++.h>

	#define MAX 100000

	using namespace std;

	int main(){

		int w[MAX];
		int k, n, bolsos=0;
		cin>>n>>k;

		for(int i=0; i<n; i++){
			cin>>w[i];
/*			while(w[i]>0){			/////
				w[i]-=k;
				bolsos++;
			}
*///			cout<<"i= "<<i<<endl<<"bolsos= "<<bolsos<<endl;
			if(w[i]%k != 0 || w[i] < k)
				bolsos+= 1;
			bolsos+=w[i]/k;
		}
		if(bolsos%2 == 0)
			cout<<bolsos/2;
		else
			cout<<bolsos/2+1;
		cout<<endl;

		return 0;
	}

/*
	FOR STR.LEN > 10, STR = "s[0]{int(n-2)}s[n-1]"
	sort(a, a+as);
	sort(b, b+bs);

*/


#include <iostream>

using namespace std;

int main()
{
    long long i,pebbles_type,pocket_size,p_found[10000],result=0,b1=0,b2=0,b3=1;
    cin>>pebbles_type>>pocket_size;
    for(i=0;i<pebbles_type;i++)
     {
        cin>>p_found[i];
        if(p_found[i]<=(pocket_size*2))
        {
            if(p_found[i]<=pocket_size)
            b1++;
        else if(p_found[i]<=(pocket_size*2))
          b2++;
        }
        else
            b3=0;
     }
     if(b3==1)
     {
         if(b1%2==0)
           result=(b1/2)+b2;
         else
           result=(b1/2)+b2+1;
     }
     else
     {
           for(i=0;i<pebbles_type;i++)
     {
        if(p_found[i]<=0)
            continue;
        if(p_found[i]<=pocket_size)
        {
            p_found[i]-=pocket_size;
            if(p_found[i+1]<=pocket_size &&i<pebbles_type)
            {
                i++;result++;
            }
            else if(p_found[i+1]>pocket_size &&i<pebbles_type)
            {
                p_found[i+1]-=pocket_size;result++;
            }
        }
        else
        {
            if(p_found[i]>(pocket_size*2))
             {
                 p_found[i]-=(pocket_size*2);i--;result++;
             }
             else
             {
                 result++;
             }
        }
     }
     }

     cout<<result;
    return 0;
}


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

int main()
{
    long long i,pebbles_type,pocket_size,p_found,result=0,b1=0,b2=0,b3=1;
    scanf("%I64d %I64d",&pebbles_type,&pocket_size);
    for(i=0;i<pebbles_type;i++)
     {
        scanf("%I64d",&p_found);
            if(p_found<=pocket_size)
            b1++;
        else if(p_found<=(pocket_size*2))
          b2++;
        else
        {
            if(p_found%pocket_size==0)
                b1+=p_found/pocket_size;
            else
               b1+=(p_found/pocket_size)+1;
        }
     }
         if(b1%2==0)
           result=(b1/2)+b2;
         else
           result=(b1/2)+b2+1;

     cout<<result;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long i,pebbles_type,pocket_size,p_found[10000],result=0,b1=0,b2=0,b3=1;cout<<11/4;
    cin>>pebbles_type>>pocket_size;
    for(i=0;i<pebbles_type;i++)
     {
        cin>>p_found[i];
            if(p_found[i]<=pocket_size)
            b1++;
        else if(p_found[i]<=(pocket_size*2))
          b2++;
        else
        {
            if(p_found[i]%pocket_size==0)
                b1+=p_found[i]/pocket_size;
            else
               b1+=(p_found[i]/pocket_size)+1;
        }
     }
         if(b1%2==0)
           result=(b1/2)+b2;
         else
           result=(b1/2)+b2+1;

     cout<<result;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long i,pebbles_type,pocket_size,p_found[10000],result=0;
    cin>>pebbles_type>>pocket_size;
    for(i=0;i<pebbles_type;i++)
     {
        cin>>p_found[i];
     }
    for(i=0;i<pebbles_type;i++)
     {
        if(p_found[i]<=0)
            continue;
        if(p_found[i]<=pocket_size)
        {
            p_found[i]-=pocket_size;
            if(p_found[i+1]<=pocket_size &&i<pebbles_type)
            {
                i++;result++;
            }
            else if(p_found[i+1]>pocket_size &&i<pebbles_type)
            {
                p_found[i+1]-=pocket_size;result++;
            }
        }
        else
        {
            if(p_found[i]>(pocket_size*2))
             {
                 p_found[i]-=(pocket_size*2);i--;result++;
             }
             else
             {
                 result++;
             }
        }

     }
     cout<<result;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long i,pebbles_type,pocket_size,p_found[10000],result=0,b1=0,b2=0,b3=1;
    cin>>pebbles_type>>pocket_size;
    for(i=0;i<pebbles_type;i++)
     {
        cin>>p_found[i];
            if(p_found[i]<=pocket_size)
            b1++;
        else if(p_found[i]<=(pocket_size*2))
          b2++;
        else
        {
            if(p_found[i]%pocket_size==0)
                b1+=p_found[i]/pocket_size;
            else
               b1+=(p_found[i]/pocket_size)+1;
        }
     }
         if(b1%2==0)
           result=(b1/2)+b2;
         else
           result=(b1/2)+b2+1;

     cout<<result;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1e5 + 10;
int main()
{
    int a[N], i, n, k;
    scanf("%d%d", &n, &k);
    for(i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    int ans = 0, s = 0;
    sort(a + 1, a + 1 + n);
    for(i = n; i >= 1; i--) {
        s = a[i] / k;
        ans += s;
        if(a[i] % k)
            ans++;
    }
    if(ans % 2)
        ans = ans / 2 + 1;
    else
        ans = ans / 2;
    printf("%d\n", ans);
    return 0;
}


#include <stdio.h>
int main()
{
    int n,k,i,cou=0;
    int ans;
    scanf("%d%d", &n, &k);
    for(i = 0; i < n; i++ )
    {
        scanf("%d", &ans);
        while(ans)
        {
            if(ans>k)
            {
                ans-=k;
                cou++;
            }
            else{
                cou++;
                ans=0;
            }
        }
    }
    printf("%d\n",(cou%2)?(cou/2+1):(cou/2));
        return 0;
}


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using  namespace std;
int main()
{
    int a[100005];
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<=n-1;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int t=2*k;
    float sum=0;
    for(int i=n-1;i>=0;i--)
    {
        if(a[i]>=t)
            sum+=a[i]/t;
        if(a[i]%t>k)
            sum+=1;
        else if(a[i]%t<=k&&a[i]%t>0)
            sum+=0.5;
    }
    int sum1;
    sum1=(int )sum;
    if(sum>sum1)
        printf("%d\n",sum1+1);
    else
        printf("%d\n",sum1);
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int s[100050];
int main()
{
  int n,m,sum=0,i;
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++)
    scanf("%d",&s[i]);
    sort(s,s+n);
    for(i=0;i<n;i++)
    {
        if(s[i]%m==0)
            sum+=s[i]/m;
        else
            sum+=s[i]/m+1;
    }
    if(sum%2==0)
        sum=sum/2;
    else
        sum=sum/2+1;
printf("%d\n",sum);
return 0;
}


#include <iostream>
#include <stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int w[100010];
int main()
{
    int n,i;
    long long k;
    while(~scanf("%d%lld",&n,&k))
    {
        for(i=0;i<n;i++)
        {
            scanf("%d",&w[i]);
        }
        sort(w,w+n);
        for(i=0;i<n;i++)
        {
            if(w[i]>=2*k)
            {
                break;
            }
        }
        int ind=i,t1=0,t2=0,t3=0;
        for(i=ind;i<n;i++)
        {
            t1+=w[i]/(2*k);
            w[i]=w[i]%(2*k);
        }
       sort(w,w+n);
       for(i=0;i<n;i++)
        {
            if(w[i]>=k)
            {
                break;
            }
        }
        ind=i;
        for(i=ind;i<n;i++)
        {
            w[i]=w[i]-k;
            t2++;
        }
        for(i=0;i<n;i++)
        {
            if(w[i]==0)
                continue;
            t2++;
        }
        t3=t2/2;
        if(t2%2==1)
            t3++;
        t1+=t3;
        printf("%d\n",t1);

    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,k,kq;
int a[10004];
int main()
{
    int i;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for (i=1; i<=n; i++) cin>>a[i];
    kq=0;
    int d=0;
    int j=0;
    sort(a+1,a+n+1);
    for (i=1; i<=n; i++)
    {
        if (a[i]>k)
        {j=i; break;}
        d++;
    }
    if (j!=0)
    {
        for (i=j; i<=n; i++)
            {
                int t=a[i]/k;
                d=d+t;
                if (a[i] % k != 0) d++;
            }
    }
    kq= d/2;
    if (d%2 ==1) kq++;
    cout<<kq;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,k,kq;
int a[10004];
int main()
{
    int i;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for (i=1; i<=n; i++) cin>>a[i];
    kq=0;
    int d=0;
    int j=0;
    sort(a+1,a+n+1);
    for (i=1; i<=n; i++)
    {
        if (a[i]>k)
        {j=i; break;}
        d++;
    }
    kq = kq+ (d/2);
    d=d%2;
    if (j!=0)
    {
    for (i=j; i<=n; i++)
    {
        int t=a[i]/k;
        d=d+t;
        if (a[i] % k != 0) d++;
    }
    kq= kq+(d/2);
    if (d%2 ==1)
    {kq++; d=0;}
    }
    if (d%2 ==1) kq++;
    cout<<kq;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,k,kq;
int a[10004];
int main()
{
    int i;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for (i=1; i<=n; i++) cin>>a[i];
    kq=0;
    int d=0;
    int j=0;
    sort(a+1,a+n+1);
    for (i=1; i<=n; i++)
    {
        if (a[i]>k)
        {j=i; break;}
        d++;
    }
    kq = kq+ (d/2);
    d=d%2;
    if (j!=0)
    {
    for (i=j; i<=n; i++)
    {
        int t=a[i]/k;
        d=d+t;
        if (a[i] % k != 0) d++;
    }
    kq= kq+(d/2);
    if (d%2 ==1) kq++;
    }
    cout<<kq;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,k,kq;
int a[100004];
int main()
{
    int i;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for (i=1; i<=n; i++) cin>>a[i];
    kq=0;
    int d=0;
    int j=0;
    sort(a+1,a+n+1);
    for (i=1; i<=n; i++)
    {
        if (a[i]>k)
        {j=i; break;}
        d++;
    }
    if (j!=0)
    {
        for (i=j; i<=n; i++)
            {
                int t=a[i]/k;
                d=d+t;
                if (a[i] % k != 0) d++;
            }
    }
    kq= d/2;
    if (d%2 ==1) kq++;
    cout<<kq;
    return 0;
}


#include <iostream>

using namespace std;
long n,k,a[100001],Ans;
long double ans;
int main()
{
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
        if (a[i]<=k)
        {
            ans+=0.5;
        }
        else
        {   ans+=a[i]/(k*2);
            if(a[i]%(k*2)<=k)
            ans+=0.5;
            else ans+=1;
        }
    }
    Ans=ans;
    if(ans==Ans)
        cout<< ans;
    else cout<< Ans+1;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,k,a[100001];
double ans;
int main()
{
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
        if (a[i]<=k)
        {
            ans+=0.5;
        }
        else
        {   ans+=a[i]/(k*2);
            if(a[i]%(k*2)<=k)
            ans+=0.5;
            else ans+=1;
        }
    }
    Ans=ans;
    if(ans==Ans)
        cout<< ans;
    else cout<< Ans+1;
    return 0;
}


#include <iostream>

using namespace std;
long n,k,a[100001],Ans;
long double ans;
int main()
{
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
        if (a[i]<=k && a[i]!=0)
        {
            ans+=0.5;
        }
        else
        {   ans+=a[i]/(k*2);
            if(a[i]%(k)<=(k*2) && (a[i]%k)!=0)
            ans+=0.5;
            else ans+=1;
        }
    }
    Ans=ans;
    if(ans==Ans)
        cout<< Ans;
    else cout<< Ans+1;
    return 0;
}


#include <iostream>

using namespace std;
long n,k,a[100001],Ans;
long double ans;
int main()
{
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
        if (a[i]<=k && a[i]!=0)
        {
            ans+=0.5;
        }
        else
        {   ans+=a[i]/(k*2);
            if(a[i]%(k)<=k && (a[i]%k)!=0)
            ans+=0.5;
            else ans+=1;
        }
    }
    Ans=ans;
    if(ans==Ans)
        cout<< Ans;
    else cout<< Ans+1;
    return 0;
}


#include <iostream>

using namespace std;
long n,k,a[100001],Ans;
long double ans;
int main()
{
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
        if (a[i]<=k)
        {
            ans+=0.5;
        }
        else
        {   ans+=a[i]/(k*2);
            if(a[i]%(k*2)<=k)
            ans+=0.5;
            else ans+=1;
        }
    }
    Ans=ans;
    if(ans==Ans)
        cout<< Ans;
    else cout<< Ans+1;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
long n,k,a[100001],Ans;
long double ans;
int main()
{
    scanf("%d%d",&n,&k);
    for (int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        if (a[i]<=k)
        {
            ans+=0.5;
        }
        else
        {   ans+=a[i]/(k*2);
        if(a[i]%(2*k))
            {if(a[i]%(2*k)<=k )
            ans+=0.5;
            else  ans+=1;
            }
        }
    }
    Ans=ans;
    if(ans==Ans)
        cout<< Ans;
    else cout<< Ans+1;
    return 0;
}


#include <iostream>

using namespace std;
long n,k,a[100001],Ans;
long double ans;
int main()
{
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
        if (a[i]<=k)
        {
            ans+=0.5;
        }
        else
        {   ans+=a[i]/(k*2);
        if(a[i]%(2*k))
            {if(a[i]%(2*k)<=k )
            ans+=0.5;
            else  ans+=1;
            }
        }
    }
    Ans=ans;
    if(ans==Ans)
        cout<< Ans;
    else cout<< Ans+1;
    return 0;
}


#include <iostream>

using namespace std;
int n,k,a[100001],Ans;
double ans;
int main()
{
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
        if (a[i]<=k)
        {
            ans+=0.5;
        }
        else
        {   ans+=a[i]/(k*2);
            if(a[i]%(k*2)<=k)
            ans+=0.5;
            else ans+=1;
        }
    }
    Ans=ans;
    if(ans==Ans)
        cout<< ans;
    else cout<< Ans+1;
    return 0;
}


#include <iostream>

using namespace std;
long n,k,a[100001],Ans;
long double ans;
int main()
{
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
        if (a[i]<=k)
        {
            ans+=0.5;
        }
        else
        {   ans+=a[i]/(k*2);
        if((a[i]%k))
            if(a[i]%(2*k)<=k )
            ans+=0.5;
            else  ans+=1;
        }
    }
    Ans=ans;
    if(ans==Ans)
        cout<< Ans;
    else cout<< Ans+1;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100005],n,k;
int main()
{
    cin>>n>>k;
    int sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]%k==0) sum+=a[i]/k;
        else sum+=(a[i]/k+1);
    }
    if(sum&1) printf("%d\n",sum/2+1);
    else printf("%d\n",sum/2);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ long long int n,k,a,m,i;
  while(cin>>n>>k)
  { m=0;
  for(i=0;i<n;++i)
  { cin>>a;
    if(a%k==0)m+=a/k;
     else m+=a/k+1;

  }
  if(m&2==0)cout<<m/2<<endl;
    else cout<<m/2+1<<endl;
 }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ int n,k,a[100001],m=0,i;
  cin>>n>>k;
  for(i=0;i<n;++i)
  { cin>>a[i];
    if(a[i]%k==0)m+=a[i]/k;
     else m+=a[i]/k+1;

  }
  if(m&2==0)cout<<m/2<<endl;
    else cout<<m/2+1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,k;
	while(cin>>n>>k)
	{
		int a[n+1],s=0;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		a[n]=0;
		while(1)
		{
		    for(i=0;i<n;i++)
		    {
			   if(a[i]>=0)
			   {
				   a[i]=a[i]-k;
				   if(a[i+1]>=0)
				   a[i+1]=a[i+1]-k;
				   s++;
				   break;
			   }
		    }
		    if(i==n-1)
		    break;
		}
		cout<<s<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ long long int n,k,a[100001],m=0,i;
  cin>>n>>k;
  for(i=0;i<n;++i)
  { cin>>a[i];
    if(a[i]%k==0)m+=a[i]/k;
     else m+=a[i]/k+1;

  }
  if(m&2==0)cout<<m/2<<endl;
    else cout<<m/2+1<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    while (cin>>n>>k)
    {
        int i,b,sum=0;
        vector <int> a;
        for (i=0;i<n;i++)
        {
            cin>>b;
            a.push_back(b);
            sum=sum+b;
        }
        sort(a.begin(),a.end());
        double sum1=0;
        int y;
        while (a.size()>0)
        {
            if (a[0]==0)
            {
                a.erase(a.begin());
                continue;
            }
            for (i=0;i<k;i++)
            {
                a[i]--;
                sum--;
            }
            sum1=sum1+0.5;
        }
        y=sum1;
        if (sum1-y==0.5)
        cout<<y+1<<endl;
        else
            cout<<sum1<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    while (cin>>n>>k)
    {
        int i,b,sum=0;
        vector <int> a;
        for (i=0;i<n;i++)
        {
            cin>>b;
            a.push_back(b);
            sum=sum+b;
        }
        sort(a.begin(),a.end());
        int sum1=0;
        while (a.size())
        {
            if (a[0]==0)
            {
                a.erase(a.begin());
                continue;
            }
            for (i=0;i<k;i++)
            {
                a[i]--;
                sum--;
            }
        RL:
            if (a[0]==0)
            {
                a.erase(a.begin());
                goto RL;
            }
            for (i=0;i<k;i++)
            {
                a[i]--;
                sum--;
            }
            sum1++;
        }
        cout<<sum1<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,i,sum=0;
	int a,b;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>a;
		if(a<=k)
			sum++;
		if(a>k)
		{
			b=a/k;
			if(a%k==0)
				sum+=b;
			else
				sum+=(b+1);
		}

	}
	b=sum/2;
	if(sum%2==0)
		cout<<b<<endl;
	else
		cout<<b+1<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,k;
	while(cin>>n>>k)
	{
		int a[n+1],s=0;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		a[n]=0;
		while(1)
		{
		    for(i=0;i<n;i++)
		    {
			   if(a[i]>0)
			   {
				   a[i]=a[i]-k;
				   if(a[i+1]>0)
				   a[i+1]=a[i+1]-k;
				   s++;
				   break;
			   }
		    }
		    if(i==n)
		    break;
		}
		cout<<s<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ int n,k,a[100001],m=0,h=0,i,max=0;
  cin>>n>>k;
  for(i=0;i<n;++i)
  { cin>>a[i];

    if(a[i]%k==0)
	{  m+=a[i]/k;
	   if(a[i]/k>max)max=a[i]/k;
    }
     else
	{
	 if(a[i]/k+1>max)max=a[i]/k+1;
	 m+=a[i]/k+1;
    }

  }
  if(max<=m-max)
   if(m&2==0)cout<<m/2<<endl;
    else cout<<m/2+1<<endl;
  else if(max&2==0)cout<<max/2<<endl;
       else cout<<max/2+1<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    while (cin>>n>>k)
    {
        int i,b,sum=0;
        vector <int> a;
        for (i=0;i<n;i++)
        {
            cin>>b;
            a.push_back(b);
            sum=sum+b;
        }
        sort(a.begin(),a.end());
        int sum1=0;
        while (a.size()>0)
        {
            if (a[0]==0)
            {
                a.erase(a.begin());
                continue;
            }
            for (i=0;i<k;i++)
            {
                a[i]--;
                sum--;
            }
            sum1++;
        }
        if (sum1%2==0)
        cout<<sum1/2<<endl;
        else
            cout<<sum1/2+1<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ long long int n,k,a,m,i;
  while(cin>>n>>k)
  { m=0;
  for(i=0;i<n;++i)
  { cin>>a;
    if(a%k==0)m+=a/k;
     else m+=a/k+1;

  }
  if(m%2==0)cout<<m/2<<endl;
    else cout<<m/2+1<<endl;
 }
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
#define MAXN 100000
#define MOD 1e9+7
#define eps 1e-7
using namespace std;

const int dir4[4][2] = {{1,0}, {0, 1}, {0, -1}, {-1, 0}};
const int dir8[8][2] = {{1,0}, {0, 1}, {0, -1}, {-1, 0}, {1,1}, {-1, 1}, {1, -1}, {-1, -1}};

int main()
{
    int n, k, a;
    long long sum = 0;
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a);
        if(a % k == 0)
            sum += (a/k);
        else
            sum += (a/k)+1;
    }
    if(sum%2)
        sum = sum/2+1;
    else
        sum = sum/2;
    printf("%lld\n", sum);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <iostream>
using namespace std;
int main()
{
    int m,n,i,k,ans;
    float sum=0;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&m);
        if(m>=2*k)
        {
            sum+=m/(2*k);
            m%=2*k;
        }
        if(m>k&&m<2*k)
        {
            sum+=1;
            m-=k;
        }
        if(m==k)
        {
            sum+=0.5;
            m=0;
        }
        if(m>0&&m<k)
            sum+=0.5;
    }
    ans=(int)sum;
    if(sum>ans)
        ans++;
    printf("%d\n",ans);
    return 0;
}


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

int main()
{
    int n,k,i,w,m;
    double s=0;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&w);
        if(w%k==0)
        {
            s+=w/k*0.5;
        }
        else
            s+=w/k*0.5+0.5;
    }
    m=s+0.5;
    printf("%d\n",m);
    return 0;
}


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

int main()
{
   int n,k;
   scanf("%d%d",&n,&k);
   int sum=0;
   while(n--)
   {
       int m;
       scanf("%d",&m);
       if(m%k)
        sum+=1+m/k;
       else
        sum+=m/k;
   }
   sum++;
   printf("%d",sum/2);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int w[10100];
int main()
{
    long long n,k,t=0;
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&w[i]);
        if(w[i]<=k){
            t++;
        }else{
            if(w[i]%k==0){
                t=t+w[i]/k;
            }else{
                t=t+w[i]/k+1;
            }
        }
    }
    if(t%2==0){
        t=t/2;
    }else{
        t=t/2+1;
    }
    printf("%lld",t);

    return 0;
}


#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
const int MAX=1e5;
int ans[MAX];
bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
    int n,k,i,cou=0;
    scanf("%d%d", &n, &k);
    for(i = 0; i < n; i++ )
    {
        scanf("%d", ans+i);
        while(1)
        {
            if(ans[i]>k&&ans[i]<=2*k)
            {
                ans[i]=0;
                cou++;
            }
            if(ans[i]>2*k){
                ans[i]-=2*k;
                cou++;
            }
            if(ans[i]<=k)
                break;
        }
    }
sort(ans,ans+n,cmp);
    for(i=0; i+1< n,ans[i]; i+=2){
        if(ans[i]||ans[i+1])
            cou++;
    }
    printf("%d\n",cou);
        return 0;
}


#include <stdio.h>
#include <stdlib.h>
int a[100000];
int cmp(const void*a,const void*b)
{
    return (*(int*)b-*(int*)a);
}
int yz(int a[],int n)
{
    int i;
    int sum=0;
    for(i=0;i<n;i++)
        if(a[i]!=0)
        sum++;
    return sum;

}
int main()
{
   int n,k,num=0;
   scanf("%d%d",&n,&k);
   int i;
   for(i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
        num+=a[i];
   }
   qsort(a,n,sizeof(int),cmp);
   int sum=0;
    while(1)
    {
        int num=0;
        for(i=0;i<n;i++)
        {
            if(a[i])
            {
                a[i]--;
                num++;
            }
            if(num==k||num>=yz(a,n))
            {
                sum++;
                break;
            }
        }
        num=0;
        for(i=0;i<n;i++)
        {
            if(a[i])
            {
                a[i]--;
                num++;
            }
            if(num==k||num>=yz(a,n))
            {
                sum++;
                break;
            }
        }
        int flag=0;
        for(i=0;i<n;i++)
            if(a[i]!=0)
            flag++;
        if(flag==0)
            break;
    }
    if(sum%2==0)
  sum/=2;
   else
   sum=sum/2+1;
    printf("%d",sum);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
const int maxn = 1e6+100;
const int inf = 0x7fffffff;
int main(void)
{
    int n,k;
    scanf("%d %d",&n,&k);
    int ans = 0;
    while(n--)
    {
        int x;
        scanf("%d",&x);
        if(x<k)
            ans++;
        else if(x>=k && x<=2*k)
            ans++;
        else
            ans+=x/(2*k);
    }
    printf("%d\n",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
const int maxn = 1e6+100;
const int inf = 0x7fffffff;
int main(void)
{
    int n,k;
    scanf("%d %d",&n,&k);
    int ans = 0;
    while(n--)
    {
        int x;
        scanf("%d",&x);
        if(x<k)
            ans++;
        else
            ans += x/(2*k);
    }
    printf("%d\n",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
const int maxn = 1e6+100;
const int inf = 0x7fffffff;
int main(void)
{
    int n,k;
    scanf("%d %d",&n,&k);
    int ans = 0;
    int left = 0;
    while(n--)
    {
        int x;
        scanf("%d",&x);
        if(left)
        {
            ans++;
            left = 0;
            if(x<=k)
                continue;
        }
        ans += x/(2*k);
        left = x%(2*k);
        if(k<left && left<2*k)
        {
            left = 0;
            ans++;
        }
        else if(left!=0)
            left = 1;
    }
    printf("%d\n",ans+left);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
const int maxn = 1e6+100;
const int inf = 0x7fffffff;
int main(void)
{
    int n,k;
    scanf("%d %d",&n,&k);
    int ans = 0;
    while(n--)
    {
        int x;
        scanf("%d",&x);
        ans += (x+k-1)/k;
    }
    printf("%d\n",(ans+1)/2)
    return 0;
}


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

int main() {
	int n;
	cin>>n;
	int ans[2*n];
	int st[2*n][2*n];
	int maxx,maxy,maxst;
	for (int i= 1; i<(2*n); i++) for (int j=0; j<i; j++) cin>>st[i][j];
	int teams=0;
	while(teams<n){
		maxx=0;
		maxy=0;
		maxst=0;
		for (int i= 1; i<(2*n); i++) for (int j=0; j<i; j++){
			if (st[i][j]>maxst){
				maxst=st[i][j];
				maxx=i;
				maxy=j;
			}
		}
		for (int i= 0; i<(2*n); i++) {st[i][maxy]=0; st[maxx][i]=0;st[i][maxx]=0; st[maxy][i]=0;}
		ans[maxx] = maxy+1;
		ans[maxy] = maxx+1;
		teams++;
	}
	string answer="";
	for(int i= 0; i<((2*n)-1); i++) cout<<ans[i]<<' ';
	cout<<ans[((2*n)-1)]<<endl;
	return 0;
}


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

int main() {
	int n;
	cin>>n;
	int ans[2*n];
	int st[2*n][2*n];
	int maxx,maxy,maxst;
	for (int i= 1; i<(2*n); i++) for (int j=0; j<i; j++) cin>>st[i][j];
	int teams=0;
	while(teams<n){
		maxx=0;
		maxy=0;
		maxst=0;
		for (int i= 1; i<(2*n); i++) for (int j=0; j<i; j++){
			if (st[i][j]>maxst){
				maxst=st[i][j];
				maxx=i;
				maxy=j;
			}
		}
		for (int i= 0; i<(2*n); i++) {st[i][maxy]=0; st[maxx][i]=0;}
		ans[maxx] = maxy+1;
		ans[maxy] = maxx+1;
	}
	for(int i= 0; i<(2*n); i++) cout<<ans[i]<<' ';
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int n,x,i,j,c=0;
vector<pair<long int,pair<long int,long int> > > s;
long int v[405]={0},ans[405];
int main() {
    ios::sync_with_stdio(false);
    cin>>n;
    for(i=1;i<2*n;i++){
        for(j=1;j<=i;j++){
            cin>>x;
            s.push_back(make_pair(x,make_pair(i+1,j)));
        }
    }
    long int st,fi,se;
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    while(!s.empty()){
        st=s.begin()->first;
        fi=s.begin()->second.first;
        se=s.begin()->second.second;
    //  cout<<st<<" "<<fi<<" "<<se<<endl;
        if(v[fi]==1||v[se]==1){
            s.erase(s.begin());
            continue;
        }
        c++;
        v[fi]=1;v[se]=1;
        ans[fi]=se;ans[se]=fi;
        if(c==n)break;
    }
    for(i=1;i<=2*n;i++){
        cout<<ans[i]<<" ";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int n,x,i,j,c=0;
vector<pair<long int,pair<long int,long int> > > s;
long int v[400005]={0},ans[400005];
int main() {
    ios::sync_with_stdio(false);
    cin>>n;
    for(i=1;i<2*n;i++){
        for(j=1;j<=i;j++){
            cin>>x;
            s.push_back(make_pair(x,make_pair(i+1,j)));
        }
    }
    long int st,fi,se;
    sort(s.begin(),s.end());
    vector<pair<long int,pair<long int,long int> > >::reverse_iterator it;
    for(it=s.rbegin();it!=s.rend();it++){
    //  cout<<st<<" "<<fi<<" "<<se<<endl;
        if(v[it->second.second]==1||v[it->second.first]==1){
            s.pop_back();
            continue;
        }
        c++;
        v[it->second.second]=1;v[it->second.first]=1;
        ans[it->second.second]=it->second.first;ans[it->second.first]=it->second.second;
        s.pop_back();
        if(c==n)break;
    }
    for(i=1;i<=2*n;i++){
        cout<<ans[i]<<" ";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int n,x,i,j;
/*long long int power(long long int p){
    if(p==1)return 2;
    if(p==0)return 1;
    long long int x=1,y;
    if(x%2)x=2;
    p=p/2;
    y=power(p);
    return x*y*y;
}*/
vector<pair<long int,pair<long int,long int> > > s;
long int v[405]={0},ans[405];
int main() {
    cin>>n;
    for(i=1;i<2*n;i++){
        for(j=1;j<=i;j++){
            cin>>x;
            s.push_back(make_pair(x,make_pair(i+1,j)));
        }
    }
    long int st,fi,se;
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    while(!s.empty()){
        st=s.begin()->first;
        fi=s.begin()->second.first;
        se=s.begin()->second.second;
    //  cout<<st<<" "<<fi<<" "<<se<<endl;
        if(v[fi]==1||v[se]==1){
            s.erase(s.begin());
            continue;
        }
        v[fi]=1;v[se]=1;
        ans[fi]=se;ans[se]=fi;
    }
    for(i=1;i<=2*n;i++){
        cout<<ans[i]<<" ";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int n,x,i,j;
vector<pair<long int,pair<long int,long int> > > s;
long int v[405]={0},ans[405];
int main() {
    ios::sync_with_stdio(false);
    cin>>n;
    for(i=1;i<2*n;i++){
        for(j=1;j<=i;j++){
            cin>>x;
            s.push_back(make_pair(x,make_pair(i+1,j)));
        }
    }
    long int st,fi,se;
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    while(!s.empty()){
        st=s.begin()->first;
        fi=s.begin()->second.first;
        se=s.begin()->second.second;
    //  cout<<st<<" "<<fi<<" "<<se<<endl;
        if(v[fi]==1||v[se]==1){
            s.erase(s.begin());
            continue;
        }
        v[fi]=1;v[se]=1;
        ans[fi]=se;ans[se]=fi;
    }
    for(i=1;i<=2*n;i++){
        cout<<ans[i]<<" ";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int n,x,i,j,c=0;
vector<pair<long int,pair<long int,long int> > > s;
long int v[400005]={0},ans[400005];
int main() {
    ios::sync_with_stdio(false);
    cin>>n;
    for(i=1;i<2*n;i++){
        for(j=1;j<=i;j++){
            cin>>x;
            s.push_back(make_pair(x,make_pair(i+1,j)));
        }
    }
    long int st,fi,se;
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    while(!s.empty()){
        st=s.begin()->first;
        fi=s.begin()->second.first;
        se=s.begin()->second.second;
    //  cout<<st<<" "<<fi<<" "<<se<<endl;
        if(v[fi]==1||v[se]==1){
            s.erase(s.begin());
            continue;
        }
        c++;
        v[fi]=1;v[se]=1;
        ans[fi]=se;ans[se]=fi;
        if(c==n)break;
    }
    for(i=1;i<=2*n;i++){
        cout<<ans[i]<<" ";
    }

    return 0;
}


#include<iostream>
#include<algorithm>

using namespace std;

#define cio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

const int maxn=4e5;

int arr[maxn];

struct team{
    int x,y,val;
}ans[maxn];

bool cmp(team n,team m){
    return n.val>m.val;
}
int main(){
    //cio;
    int n;
    while(cin>>n){
        n<<=1;
        int ct=0;
        for(int i=2;i<=n;i++){
            for(int j=1;j<i;j++){
               cin>>ans[++ct].val;
                ans[ct].x=i,ans[ct].y=j;
            }
        }
       sort(ans+1,ans+1+ct,cmp);
       fill(arr,arr+maxn,0);
        for(int i=1;i<=ct;i++){
            int x=ans[i].x,y=ans[i].y;
           // cout<<x<<' '<<y<<' '<<ans[i].val<<endl;
            if(arr[x]||arr[y])continue;
            arr[x]=y,arr[y]=x;
        }
        for(int i=1;i<=n;i++){
            cout<<arr[i]<<(i==n?'\n':' ');
        }
    }
    return 0;
}


#include<iostream>
#include<algorithm>

using namespace std;

#define cio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

const int maxn=2e5;

int arr[maxn];

struct team{
    int x,y,val;
}ans[maxn];

bool cmp(team n,team m){
    return n.val>m.val;
}
int main(){
    //cio;
    int n;
    while(cin>>n){
        n<<=1;
        int ct=0;
        for(int i=2;i<=n;i++){
            for(int j=1;j<i;j++){
                cin>>ans[++ct].val;
                ans[ct].x=i,ans[ct].y=j;
            }
        }
        sort(ans+1,ans+1+ct,cmp);
       // cout<<ct<<endl;
        for(int i=1;i<=ct;i++){
            int x=ans[i].x,y=ans[i].y;
           // cout<<x<<' '<<y<<' '<<ans[i].val<<endl;
            if(arr[x]||arr[y])continue;
            arr[x]=y,arr[y]=x;
        }
        for(int i=1;i<=n;i++){
            cout<<arr[i]<<(i==n?'\n':' ');
        }
    }
    return 0;
}