#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int main(){

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

	while (t--) {
	//	cout <<"hya"<<endl;
	int n;
	scanf("%d",&n);

	int a[10001];
	vector<int> v;
	memset(a, 0,sizeof(a));
	int flag=0;
	for(int i=0;i<n;i++){
		int r;
		scanf("%d",&r);
		a[r]++;
		if(a[r]==2)v.pb(r);
		if(a[r]>=4)flag=r;
	}
		int x,y;
			float p;
	if(flag!=0){
	//	cout << flag << " " <<flag<<" "<<flag << " "<<flag<<endl;
		printf("%d %d %d %d", flag, flag, flag, flag);
		continue;
	}

		sort(v.begin(),v.end());

		float mini=FLT_MAX;
		for(int i=1;i<v.size();i++){
		for(int j=0;j<i;j++){
			p= v[i]/float(v[j]) + v[j]/float(v[i]);
			if(p<mini){
				mini=p;
				x=v[i];
				y=v[j];
			}
		}
}
//cout << x << " " <<x << " " << y << " " << y <<endl;
printf("%d %d %d %d",x,x,y,y);
//
//c
////	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
//	int x,y;
//
//	float p;
////	float a;
//	float max=99999999;
//
//// 	cout <<endl;
//	for(int i=1;i<v.size();i++){
//		for(int j=0;j<i;j++){
//			if(v[i]>v[j]) p= v[i]/v[j];
//			else p= v[j]/v[i];
//			if(p < max){
//			max= p;
//			x=v[i];
//			y=v[j];
//		}
//		}
//	}
//
//
//
//
//	}
//
//
}
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int a[10001];
int main(){

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

	while (t--) {

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

	vector<int> v;
	memset(a, 0,sizeof(a));
	int flag=0;
	for(int i=0;i<n;i++){
		int r;
		scanf("%d",&r);
		a[r]++;
		if(a[r]==2)v.pb(r);
		if(a[r]>=4)flag=r;
	}
		int x,y;
			float p;
	if(flag!=0){
	//	cout << flag << " " <<flag<<" "<<flag << " "<<flag<<endl;
		printf("%d %d %d %d \n", flag, flag, flag, flag);
		continue;
	}

	//	sort(v.begin(),v.end());

		float mini=FLT_MAX;
		int m=v.size();
		for(int i=1;i<m;i++){
		for(int j=0;j<i;j++){
			p= v[i]/float(v[j]) + v[j]/float(v[i]);
			if(p<mini){
				mini=p;
				x=v[i];
				y=v[j];
			}
		}
}
//cout << x << " " <<x << " " << y << " " << y <<endl;
printf("%d %d %d %d \n",x,x,y,y);
//
//c
////	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
//	int x,y;
//
//	float p;
////	float a;
//	float max=99999999;
//
//// 	cout <<endl;
//	for(int i=1;i<v.size();i++){
//		for(int j=0;j<i;j++){
//			if(v[i]>v[j]) p= v[i]/v[j];
//			else p= v[j]/v[i];
//			if(p < max){
//			max= p;
//			x=v[i];
//			y=v[j];
//		}
//		}
//	}
//
//
//
//
//	}
//
//
}
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int a[10001];
int main(){

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

	while (t--) {

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

	vector<int> v;
	memset(a, 0,sizeof(a));
	int flag=0;
	for(int i=0;i<n;i++){
		int r;
		scanf("%d",&r);
		a[r]++;
		if(a[r]==2)v.pb(r);
		if(a[r]>=4)flag=r;
	}
		int x,y;
			float p;
	if(flag!=0){
	//	cout << flag << " " <<flag<<" "<<flag << " "<<flag<<endl;
		printf("%d %d %d %d \n", flag, flag, flag, flag);
		continue;
	}

	//	sort(v.begin(),v.end());

		float mini=FLT_MAX;
		for(int i=1;i<v.size();i++){
		for(int j=0;j<i;j++){
			p= v[i]/float(v[j]) + v[j]/float(v[i]);
			if(p<mini){
				mini=p;
				x=v[i];
				y=v[j];
			}
		}
}
//cout << x << " " <<x << " " << y << " " << y <<endl;
printf("%d %d %d %d \n",x,x,y,y);
//
//c
////	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
//	int x,y;
//
//	float p;
////	float a;
//	float max=99999999;
//
//// 	cout <<endl;
//	for(int i=1;i<v.size();i++){
//		for(int j=0;j<i;j++){
//			if(v[i]>v[j]) p= v[i]/v[j];
//			else p= v[j]/v[i];
//			if(p < max){
//			max= p;
//			x=v[i];
//			y=v[j];
//		}
//		}
//	}
//
//
//
//
//	}
//
//
}
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int a[10001];
int main(){

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

	while (t--) {

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

	vector<double> v;
	memset(a, 0,sizeof(a));
	int flag=0;
	for(int i=0;i<n;i++){
		int r;
		scanf("%d",&r);
		a[r]++;
		if(a[r]==2)v.pb(r);
		if(a[r]>=4)flag=r;
	}
		int  x,y;
			double p;
	if(flag!=0){
	//	cout << flag << " " <<flag<<" "<<flag << " "<<flag<<endl;
		printf("%d %d %d %d \n", flag, flag, flag, flag);
		continue;
	}

		sort(v.begin(),v.end());

		double mini=FLT_MAX;
		int m=v.size();
		for(int i=1;i<m;i++){
			p= v[i]*1.0/(v[i-1]) + v[i-1]*1.0/(v[i]);
			if(p<mini){
				mini=p;
				x=v[i];
				y=v[i-1];

		}
}
//cout << x << " " <<x << " " << y << " " << y <<endl;
printf("%d %d %d %d \n",x,x,y,y);
//
//c
////	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
//	int x,y;
//
//	float p;
////	float a;
//	float max=99999999;
//
//// 	cout <<endl;
//	for(int i=1;i<v.size();i++){
//		for(int j=0;j<i;j++){
//			if(v[i]>v[j]) p= v[i]/v[j];
//			else p= v[j]/v[i];
//			if(p < max){
//			max= p;
//			x=v[i];
//			y=v[j];
//		}
//		}
//	}
//
//
//
//
//	}
//
//
}
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int main(){

	int t; cin >> t;

	while (t--) {

	int n;cin >> n;
	float arr[n];
	map<float,float> m;
	vector<float> v;
	for(int i=0;i<n;i++){
		cin >> arr[i];

		m[arr[i]] = (m[arr[i]] +1);
		if(m[arr[i]] >2) m[arr[i]]=m[arr[i]]-2;
	//	cout << m[arr[i]] <<endl;
		if(m[arr[i]] ==2){
		v.pb(arr[i]);
	//	m[arr[i]]==0;
	//	cout <<" hala" <<endl;
		}
	}
//	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
	float x,y;

	float p;
//	float a;
	float max=99999999;

// 	cout <<endl;
	for(int i=1;i<v.size();i++){
		for(int j=0;j<i;j++){
			if(v[i]>v[j]) p= v[i]/v[j];
			else p= v[j]/v[i];
			if(p < max){
			max= p;
			x=v[i];
			y=v[j];
		}
		}
	}
	cout << x << " " <<x << " " << y << " " << y <<endl;

	}

    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int a[10001];
int main(){

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

	while (t--) {

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

	vector<int> v;
	memset(a, 0,sizeof(a));
	int flag=0;
	for(int i=0;i<n;i++){
		int r;
		scanf("%d",&r);
		a[r]++;
		if(a[r]==2)v.pb(r);
		if(a[r]>=4)flag=r;
	}
		int x,y;
			float p;
	if(flag!=0){
	//	cout << flag << " " <<flag<<" "<<flag << " "<<flag<<endl;
		printf("%d %d %d %d \n", flag, flag, flag, flag);
		continue;
	}

	//	sort(v.begin(),v.end());

		float mini=FLT_MAX;
		int m=v.size();
		for(int i=1;i<m;i++){
			p= v[i]/float(v[i-1]) + v[i-1]/float(v[i]);
			if(p<mini){
				mini=p;
				x=v[i];
				y=v[i-1];

		}
}
//cout << x << " " <<x << " " << y << " " << y <<endl;
printf("%d %d %d %d \n",x,x,y,y);
//
//c
////	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
//	int x,y;
//
//	float p;
////	float a;
//	float max=99999999;
//
//// 	cout <<endl;
//	for(int i=1;i<v.size();i++){
//		for(int j=0;j<i;j++){
//			if(v[i]>v[j]) p= v[i]/v[j];
//			else p= v[j]/v[i];
//			if(p < max){
//			max= p;
//			x=v[i];
//			y=v[j];
//		}
//		}
//	}
//
//
//
//
//	}
//
//
}
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int main(){

	int t; cin >> t;

	while (t--) {

	int n;cin >> n;

	int a[10001];
	vector<int> v;
	memset(a, 0,sizeof(a));
	int flag=0;
	for(int i=0;i<n;i++){
		int r;
		cin >> r;
		a[r]++;
		if(a[r]==2)v.pb(r);
		if(a[r]>=4)flag=r;
	}
		int x,y;
			float p;
	if(flag!=0){
		cout << flag << " " <<flag<<" "<<flag << " "<<flag<<endl;
		continue;
	}

		sort(v.begin(),v.end());

		float mini=FLT_MAX;
		for(int i=1;i<v.size();i++){
		for(int j=0;j<i;j++){
			p= v[i]/float(v[j]) + v[j]/float(v[i]);
			if(p<mini){
				mini=p;
				x=v[i];
				y=v[j];
			}
		}
}
cout << x << " " <<x << " " << y << " " << y <<endl;
//
//c
////	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
//	int x,y;
//
//	float p;
////	float a;
//	float max=99999999;
//
//// 	cout <<endl;
//	for(int i=1;i<v.size();i++){
//		for(int j=0;j<i;j++){
//			if(v[i]>v[j]) p= v[i]/v[j];
//			else p= v[j]/v[i];
//			if(p < max){
//			max= p;
//			x=v[i];
//			y=v[j];
//		}
//		}
//	}
//
//
//
//
//	}
//
//
}
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int main(){

	int t; cin >> t;

	while (t--) {

		int n;cin >> n;
	float arr[n];
	map<float,float> m;
	vector<float> v;
	for(int i=0;i<n;i++){
		cin >> arr[i];

		m[arr[i]] = (m[arr[i]] +1);
		if(m[arr[i]] >2) m[arr[i]]=m[arr[i]]-2;
	//	cout << m[arr[i]] <<endl;
		if(m[arr[i]] ==2){
		v.pb(arr[i]);
	//	m[arr[i]]==0;
	//	cout <<" hala" <<endl;
		}
	}
//	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
	float x,y;

	float p;
	float a;
	float max=99999999;

// 	cout <<endl;
	for(int i=1;i<v.size();i++){
		for(int j=0;j<i;j++){
			p=v[i]+v[j];
			a= v[i]*v[j];
			if(((p*p)/a) < max){
			max= ((p*p)/a);
			x=v[i];
			y=v[j];
		}
		}
	}
	cout << x << " " <<x << " " << y << " " << y <<endl;

	}

    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int main(){

	int t; cin >> t;

	while (t--) {

	int n;cin >> n;

	int a[10001];
	vector<int> v;
	memset(a, 0,sizeof(a));
	int flag=0;
	for(int i=0;i<n;i++){
		int r;
		cin >> r;
		a[r]++;
		if(a[r]==2)v.pb(r);
		if(a[r]>=4)flag=r;
	}
		int x,y;
			float p;
	if(flag!=0){
		cout << flag << " " <<flag<<" "<<flag << " "<<flag<<endl;
		continue;
	}

		sort(v.begin(),v.end());

		float mini=FLT_MAX;
		for(int i=1;i<v.size();i++){
		for(int j=0;j<i;j++){
			p= v[i]/float(v[j]) + v[j]/float(v[i]);

			if(p<mini){
				mini=p;
				x=v[i];
				y=v[j];
			}
		}

	cout << x << " " <<x << " " << y << " " << y <<endl;
}
//
//c
////	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
//	int x,y;
//
//	float p;
////	float a;
//	float max=99999999;
//
//// 	cout <<endl;
//	for(int i=1;i<v.size();i++){
//		for(int j=0;j<i;j++){
//			if(v[i]>v[j]) p= v[i]/v[j];
//			else p= v[j]/v[i];
//			if(p < max){
//			max= p;
//			x=v[i];
//			y=v[j];
//		}
//		}
//	}
//
//
//
//
//	}
//
//
}
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int main(){

	int t; cin >> t;

	while (t--) {

	int n;cin >> n;

	int a[10001];
	vector<int> v;
	memset(a, 0,sizeof(a));
	int flag=0;
	for(int i=0;i<n;i++){
		int r;
		cin >> r;
		a[r]++;
		if(a[r]==2)v.pb(r);
		if(a[r]>=4)flag=r;
	}
		int x,y;
			float p;
	if(flag!=0){
		cout << flag << " " <<flag<<" "<<flag << " "<<flag<<endl;
	}

		sort(v.begin(),v.end());

		float mini=FLT_MAX;
		for(int i=1;i<v.size();i++){
		for(int j=0;j<i;j++){
			p= v[i]/float(v[j]) + v[j]/float(v[i]);

			if(p<mini){
				mini=p;
				x=v[i];
				y=v[j];
			}
		}

	cout << x << " " <<x << " " << y << " " << y <<endl;
}
//
//c
////	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
//	int x,y;
//
//	float p;
////	float a;
//	float max=99999999;
//
//// 	cout <<endl;
//	for(int i=1;i<v.size();i++){
//		for(int j=0;j<i;j++){
//			if(v[i]>v[j]) p= v[i]/v[j];
//			else p= v[j]/v[i];
//			if(p < max){
//			max= p;
//			x=v[i];
//			y=v[j];
//		}
//		}
//	}
//
//
//
//
//	}
//
//
}
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int a[10001];
int main(){

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

	while (t--) {

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

	vector<int> v;
	memset(a, 0,sizeof(a));
	int flag=0;
	for(int i=0;i<n;i++){
		int r;
		scanf("%d",&r);
		a[r]++;
		if(a[r]==2)v.pb(r);
		if(a[r]>=4)flag=r;
	}
		int x,y;
			float p;
	if(flag!=0){
	//	cout << flag << " " <<flag<<" "<<flag << " "<<flag<<endl;
		printf("%d %d %d %d \n", flag, flag, flag, flag);
		continue;
	}

	//	sort(v.begin(),v.end());

		float mini=FLT_MAX;
		int m=v.size();
		for(int i=1;i<m;i++){
			p= v[i]*1.0/float(v[i-1]) + v[i-1]*1.0/float(v[i]);
			if(p<mini){
				mini=p;
				x=v[i];
				y=v[i-1];

		}
}
//cout << x << " " <<x << " " << y << " " << y <<endl;
printf("%d %d %d %d \n",x,x,y,y);
//
//c
////	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
//	int x,y;
//
//	float p;
////	float a;
//	float max=99999999;
//
//// 	cout <<endl;
//	for(int i=1;i<v.size();i++){
//		for(int j=0;j<i;j++){
//			if(v[i]>v[j]) p= v[i]/v[j];
//			else p= v[j]/v[i];
//			if(p < max){
//			max= p;
//			x=v[i];
//			y=v[j];
//		}
//		}
//	}
//
//
//
//
//	}
//
//
}
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back

using namespace std;
int main(){

	int t; cin >> t;

	while (t--) {

	int n;cin >> n;

	int a[10001];
	vector<int> v;
	memset(a, 0,sizeof(a));
	int flag=0;
	for(int i=0;i<n;i++){
		int r;
		cin >> r;
		a[r]++;
		if(a[r]==2)v.pb(r);
		if(a[r]>=4)flag=a[r];
	}
		int x,y;
			float p;
	if(flag!=0){
		cout << flag << " " <<flag<<" "<<flag << " "<<flag<<endl;
	}
	else {
		sort(v.begin(),v.end());

		float mini=FLT_MAX;
		for(int i=1;i<v.size();i++){
		for(int j=0;j<i;j++){
			p= v[i]/float(v[j]) + v[j]/float(v[i]);

			if(p<mini){
				mini=p;
				x=v[i];
				y=v[j];
			}
		}
	}
	cout << x << " " <<x << " " << y << " " << y <<endl;
}
//
//c
////	for(int j=0;j<v.size();j++)cout << v[j] <<" ";
//	int x,y;
//
//	float p;
////	float a;
//	float max=99999999;
//
//// 	cout <<endl;
//	for(int i=1;i<v.size();i++){
//		for(int j=0;j<i;j++){
//			if(v[i]>v[j]) p= v[i]/v[j];
//			else p= v[j]/v[i];
//			if(p < max){
//			max= p;
//			x=v[i];
//			y=v[j];
//		}
//		}
//	}
//
//
//
//
//	}
//
//
}
    return 0;
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	while(tc--) {
		LL n;
		scn(n);

		LL store[n];
		for(LL i=0;i<n;i++)
			scn(store[i]);

		sort(store, store+n);

		vector<LL>ps;
		for(LL i=0;i<n;i++) {
			if(store[i]==store[i+1]) {
				ps.push_back(store[i]);
				i++;
			}
		}

		sort(ps.begin(), ps.end());
		bool finished = false;
		for(LL i=1;i<ps.size();i++){
			if(ps[i]==ps[i-1]) {
				cout<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<endl;
				finished = true;
			}
		}

		if(!finished) {
			if(ps.size()%2==0) {
				cout<<ps[ps.size()/2]<<" "<<ps[ps.size()/2]<<" "<<ps[ps.size()/2-1]<<" "<<ps[ps.size()/2-1]<<endl;
			} else {
				LL x=ps.size()/2;
				if((ps[x]+ps[x-1])*(ps[x]+ps[x-1])/(ps[x]*ps[x-1]) < (ps[x]+ps[x+1])*(ps[x]+ps[x+1])/(ps[x]*ps[x+1])) {
					cout<<ps[x]<<" "<<ps[x]<<" "<<ps[x-1]<<" "<<ps[x-1]<<endl;
				} else {
					cout<<ps[x]<<" "<<ps[x]<<" "<<ps[x+1]<<" "<<ps[x+1]<<endl;
				}
			}
		}
	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	while(tc--) {
		LL n;
		scn(n);

		LL store[n];
		for(LL i=0;i<n;i++)
			scn(store[i]);

		sort(store, store+n);

		vector<long double>ps;
		for(LL i=0;i<n;i++) {
			if(i<n && store[i]==store[i+1]) {
				ps.push_back(store[i]);
				i++;
			}
		}

		sort(ps.begin(), ps.end());
		bool finished = false;
		for(LL i=1;i<ps.size();i++){
			if(ps[i]==ps[i-1]) {
				cout<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<endl;
				finished = true;
			}
		}

		if(!finished) {
			if(ps.size()%2==0) {
				// cout<<"here1"<<endl;
				cout<<ps[ps.size()/2]<<" "<<ps[ps.size()/2]<<" "<<ps[ps.size()/2-1]<<" "<<ps[ps.size()/2-1]<<endl;
			} else {
				LL x=ps.size()/2;
				if((ps[x]+ps[x-1])*(ps[x]+ps[x-1])/(ps[x]*ps[x-1]) < ((ps[x]+ps[x+1])*(ps[x]+ps[x+1]))/(ps[x]*ps[x+1])) {
					// cout<<"here2"<<endl;
					cout<<ps[x]<<" "<<ps[x]<<" "<<ps[x-1]<<" "<<ps[x-1]<<endl;
				} else {
					// cout<<"here3"<<endl;
					cout<<ps[x]<<" "<<ps[x]<<" "<<ps[x+1]<<" "<<ps[x+1]<<endl;
				}
			}
		}
	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	LL cnt[10010];

	memset(cnt, 0, sizeof(cnt));

	while(tc--) {
		LL n;
		scn(n);

		// memset(cnt, 0, sizeof(cnt));

		LL tmp, mmax=0;
		for(LL i=0;i<n;i++) {
			scn(tmp);
			cnt[tmp]++;
			if(tmp>mmax)mmax=tmp;
		}

		vector<long double>ps;
		for(LL i=0;i<=mmax;i++) {
			for(LL j=0;j<cnt[i]/2 && j<2;j++)
				ps.push_back(i);
			cnt[i]=0;
		}

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		double mind=INF;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			long double diff = (ps[i+1]+ps[i])*(ps[i+1]+ps[i])/(ps[i]*ps[i+1]);
			if(diff<mind) {
				mind=diff;
				mini=i;
			}
			// cout<<"diff="<<diff<<endl;
		}

		cout<<ps[mini]<<" "<<ps[mini]<<" "<<ps[mini+1]<<" "<<ps[mini+1]<<endl;

	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	while(tc--) {
		LL n;
		scn(n);

		LL store[n];
		for(LL i=0;i<n;i++)
			scn(store[i]);

		sort(store, store+n);

		vector<long double>ps;
		for(LL i=0;i<n;i++) {
			if(store[i]==store[i+1]) {
				ps.push_back(store[i]);
				i++;
			}
		}

		// sort(ps.begin(), ps.end());
		bool finished = false;
		for(LL i=1;i<ps.size();i++){
			if(ps[i]==ps[i-1]) {
				cout<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<endl;
				finished = true;
				break;
			}
		}

		if(!finished) {
			LL minans, mind=INF;
			for(LL i=0;i<ps.size()-1;i++) {
				if((ps[i+1]-ps[i])<=mind) {
					mind=ps[i+1]-ps[i];
					minans=i;
				}
			}

			cout<<ps[minans]<<" "<<ps[minans]<<" "<<ps[minans+1]<<" "<<ps[minans+1]<<endl;
		}
	}
}


#include<bits/stdc++.h>

#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	LL cnt[10010];

	memset(cnt, 0, sizeof(cnt));

	while(tc--) {
		LL n;
		scn(n);

		LL tmp, mmax=0;
		for(LL i=0;i<n;i++) {
			scn(tmp);
			cnt[tmp]++;
			if(tmp>mmax)mmax=tmp;
		}

		vector<long double>ps;
		for(LL i=0;i<=mmax;i++) {
			for(LL j=0;j<cnt[i]/2 && j<2;j++)
				ps.push_back(i);
			cnt[i]=0;
		}

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		long double mind=INF, diff;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			diff = ((LD)(ps[i+1]+ps[i])*(LD)(ps[i+1]+ps[i]))/(LD)(ps[i]*ps[i+1]);
			if(diff<mind) {
				mind=diff;
				mini=i;
			}
			// cout<<"diff="<<diff<<endl;
		}

		cout<<ps[mini]<<" "<<ps[mini]<<" "<<ps[mini+1]<<" "<<ps[mini+1]<<endl;

	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	LL cnt[10010];

	while(tc--) {
		LL n;
		scn(n);

		memset(cnt, 0, sizeof(cnt));

		LL store[n];
		for(LL i=0;i<n;i++) {
			scn(store[i]);
			cnt[store[i]]++;
		}

		vector<long double>ps;
		for(LL i=0;i<10010;i++) {
			if(cnt[i]>1) {
				for(LL j=0;j<cnt[i]/2;j++)
					ps.push_back(i);
			}
		}

		// sort(ps.begin(), ps.end());

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		bool finished = false;
		for(LL i=1;i<ps.size();i++){
			if(ps[i]==ps[i-1]) {
				cout<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<endl;
				finished = true;
				break;
			}
		}

		if(!finished) {
			double mind=INF;
			LL mini;
			for(LL i=0;i<ps.size()-1;i++) {
				// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
				if((ps[i+1]-ps[i])*(ps[i+1]-ps[i])/(ps[i]*ps[i+1])<=mind) {
					mind=(ps[i+1]-ps[i])*(ps[i+1]-ps[i])/(ps[i]*ps[i+1]);
					mini=i;
				}
			}

			cout<<ps[mini]<<" "<<ps[mini]<<" "<<ps[mini+1]<<" "<<ps[mini+1]<<endl;
		}
	}
}


#include<bits/stdc++.h>

#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%d", &a)

using namespace std;
LL cnt[10010];

int main() {
	LL tc;
	scn(tc);

	// memset(cnt, 0, sizeof(cnt));

	while(tc--) {
		LL n;
		scn(n);

		map<LL,LL>m;
		m.clear();

		LL tmp;
		// , mmax=0;
		for(LL i=0;i<n;i++) {
			scn(tmp);
			m[tmp]++;
			// if(tmp>mmax)mmax=tmp;
		}

		vector<LL>ps;

		for(auto x:m)
			for(LL i=0;x.second>1 && i<2 && i<x.second/2;i++)
				ps.push_back(x.first);

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		double mind=INF, diff;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			diff = ((LD)(ps[i+1]+ps[i])*(LD)(ps[i+1]+ps[i]))/(LD)(ps[i]*ps[i+1]);
			if(diff<mind) {
				mind=diff;
				mini=i;
			}
			// cout<<"diff="<<diff<<endl;
		}

		// cout<<ps[mini],ps[mini],ps[mini+1],ps[mini+1]<<endl;
		printf("%lld %lld %lld %lld\n",ps[mini],ps[mini],ps[mini+1],ps[mini+1]);
	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	LL cnt[10010];

	while(tc--) {
		LL n;
		scn(n);

		memset(cnt, 0, sizeof(cnt));

		LL store[n];
		for(LL i=0;i<n;i++) {
			scn(store[i]);
			cnt[store[i]]++;
		}

		vector<long double>ps;
		for(LL i=0;i<10010;i++) {
			for(LL j=0;j<cnt[i]/2 && j<2;j++)
				ps.push_back(i);
		}

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		double mind=INF;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			double diff = (ps[i+1]+ps[i])*(ps[i+1]+ps[i])/(ps[i]*ps[i+1]);
			if(diff<mind) {
				mind=diff;
				mini=i;
			}
		}

		cout<<ps[mini]<<" "<<ps[mini]<<" "<<ps[mini+1]<<" "<<ps[mini+1]<<endl;

	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	while(tc--) {
		LL n;
		scn(n);

		LL store[n];
		for(LL i=0;i<n;i++)
			scn(store[i]);

		sort(store, store+n);

		vector<long double>ps;
		for(LL i=0;i<n;i++) {
			if(store[i]==store[i+1]) {
				ps.push_back(store[i]);
				i++;
			}
		}

		sort(ps.begin(), ps.end());
		bool finished = false;
		for(LL i=1;i<ps.size();i++){
			if(ps[i]==ps[i-1]) {
				cout<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<endl;
				finished = true;
			}
		}

		if(!finished) {
			if(ps.size()%2==0) {
				// cout<<"here1"<<endl;
				cout<<ps[ps.size()/2]<<" "<<ps[ps.size()/2]<<" "<<ps[ps.size()/2-1]<<" "<<ps[ps.size()/2-1]<<endl;
			} else {
				LL x=ps.size()/2;
				if((ps[x]+ps[x-1])*(ps[x]+ps[x-1])/(ps[x]*ps[x-1]) < ((ps[x]+ps[x+1])*(ps[x]+ps[x+1]))/(ps[x]*ps[x+1])) {
					// cout<<"here2"<<endl;
					cout<<ps[x]<<" "<<ps[x]<<" "<<ps[x-1]<<" "<<ps[x-1]<<endl;
				} else {
					// cout<<"here3"<<endl;
					cout<<ps[x]<<" "<<ps[x]<<" "<<ps[x+1]<<" "<<ps[x+1]<<endl;
				}
			}
		}
	}
}


#include<bits/stdc++.h>

#define LL int
#define LD long double
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%d", &a)

using namespace std;
LL cnt[10010];

int main() {
	LL tc;
	scn(tc);

	// memset(cnt, 0, sizeof(cnt));

	while(tc--) {
		LL n;
		scn(n);

		map<LL,LL>m;
		m.clear();

		LL tmp;
		// , mmax=0;
		for(LL i=0;i<n;i++) {
			scn(tmp);
			m[tmp]++;
			// if(tmp>mmax)mmax=tmp;
		}

		vector<LL>ps;

		for(auto x:m)
			for(LL i=0;x.second>1 && i<2 && i<x.second/2;i++)
				ps.push_back(x.first);

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		double mind=INF, diff;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			diff = ((LD)(ps[i+1]+ps[i])*(LD)(ps[i+1]+ps[i]))/(LD)(ps[i]*ps[i+1]);
			if(diff<mind) {
				mind=diff;
				mini=i;
			}
			// cout<<"diff="<<diff<<endl;
		}

		// cout<<ps[mini],ps[mini],ps[mini+1],ps[mini+1]<<endl;
		printf("%d %d %d %d\n",ps[mini],ps[mini],ps[mini+1],ps[mini+1]);
	}
}


#include<bits/stdc++.h>

#define LL int
#define LD long double
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%d", &a)

using namespace std;
LL cnt[10010];

int main() {
	LL tc;
	scn(tc);

	memset(cnt, 0, sizeof(cnt));

	while(tc--) {
		LL n;
		scn(n);

		LL tmp, mmax=0;
		for(LL i=0;i<n;i++) {
			scn(tmp);
			cnt[tmp]++;
			if(tmp>mmax)mmax=tmp;
		}

		vector<LL>ps;
		for(LL i=0;i<=mmax;i++) {
			for(LL j=0;j<cnt[i]/2 && j<2;j++)
				ps.push_back(i);
			cnt[i]=0;
		}

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		double mind=INF, diff;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			diff = ((LD)(ps[i+1]+ps[i])*(LD)(ps[i+1]+ps[i]))/(LD)(ps[i]*ps[i+1]);
			if(diff<mind) {
				mind=diff;
				mini=i;
			}
			// cout<<"diff="<<diff<<endl;
		}

		// cout<<ps[mini],ps[mini],ps[mini+1],ps[mini+1]<<endl;
		printf("%d %d %d %d\n",ps[mini],ps[mini],ps[mini+1],ps[mini+1]);
	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	LL cnt[10010];

	while(tc--) {
		LL n;
		scn(n);

		memset(cnt, 0, sizeof(cnt));

		LL store[n];
		for(LL i=0;i<n;i++) {
			scn(store[i]);
			cnt[store[i]]++;
		}

		vector<long double>ps;
		for(LL i=0;i<10010;i++) {
			for(LL j=0;j<cnt[i]/2 && j<2;j++)
				ps.push_back(i);
		}

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		double mind=INF;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			double diff = (ps[i+1]-ps[i])*(ps[i+1]-ps[i])/(ps[i]*ps[i+1]);
			if(diff<=mind) {
				mind=diff;
				mini=i;
			}
		}

		cout<<ps[mini]<<" "<<ps[mini]<<" "<<ps[mini+1]<<" "<<ps[mini+1]<<endl;

	}
}


#include<bits/stdc++.h>

#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;
LL cnt[10010];

int main() {
	LL tc;
	scn(tc);

	// memset(cnt, 0, sizeof(cnt));

	while(tc--) {
		LL n;
		scn(n);

		map<LL,LL>m;
		m.clear();

		LL tmp;
		// , mmax=0;
		for(LL i=0;i<n;i++) {
			scn(tmp);
			m[tmp]++;
			// if(tmp>mmax)mmax=tmp;
		}

		vector<LL>ps;

		for(auto x:m)
			for(LL i=0;x.second>1 && i<2 && i<x.second/2;i++)
				ps.push_back(x.first);

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		double mind=INF, diff;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			diff = ((LD)(ps[i+1]+ps[i])*(LD)(ps[i+1]+ps[i]))/(LD)(ps[i]*ps[i+1]);
			if(diff<mind) {
				mind=diff;
				mini=i;
			}
			// cout<<"diff="<<diff<<endl;
		}

		// cout<<ps[mini],ps[mini],ps[mini+1],ps[mini+1]<<endl;
		printf("%lld %lld %lld %lld\n",ps[mini],ps[mini],ps[mini+1],ps[mini+1]);
	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	LL cnt[10010];

	memset(cnt, 0, sizeof(cnt));

	while(tc--) {
		LL n;
		scn(n);

		// memset(cnt, 0, sizeof(cnt));

		LL store[n];
		for(LL i=0;i<n;i++) {
			scn(store[i]);
			cnt[store[i]]++;
		}

		vector<long double>ps;
		for(LL i=0;i<10010;i++) {
			for(LL j=0;j<cnt[i]/2 && j<2;j++)
				ps.push_back(i);
			cnt[i]=0;
		}

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		double mind=INF;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			long double diff = (ps[i+1]+ps[i])*(ps[i+1]+ps[i])/(ps[i]*ps[i+1]);
			if(diff<mind) {
				mind=diff;
				mini=i;
			}
			// cout<<"diff="<<diff<<endl;
		}

		cout<<ps[mini]<<" "<<ps[mini]<<" "<<ps[mini+1]<<" "<<ps[mini+1]<<endl;

	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	while(tc--) {
		LL n;
		scn(n);

		LL store[n];
		for(LL i=0;i<n;i++)
			scn(store[i]);

		sort(store, store+n);

		vector<long double>ps;
		for(LL i=0;i<n;i++) {
			if(store[i]==store[i+1]) {
				ps.push_back(store[i]);
				i++;
			}
		}

		// sort(ps.begin(), ps.end());

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		bool finished = false;
		for(LL i=1;i<ps.size();i++){
			if(ps[i]==ps[i-1]) {
				// cout<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<endl;
				finished = true;
				break;
			}
		}

		if(!finished) {
			double mind=INF;
			LL mini;
			for(LL i=0;i<ps.size()-1;i++) {
				// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
				if((ps[i+1]-ps[i])*(ps[i+1]-ps[i])/(ps[i]*ps[i+1])<=mind) {
					mind=(ps[i+1]-ps[i])*(ps[i+1]-ps[i])/(ps[i]*ps[i+1]);
					mini=i;
				}
			}

			cout<<ps[mini]<<" "<<ps[mini]<<" "<<ps[mini+1]<<" "<<ps[mini+1]<<endl;
		}
	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	LL cnt[10010];

	while(tc--) {
		LL n;
		scn(n);

		memset(cnt, 0, sizeof(cnt));

		LL store[n];
		for(LL i=0;i<n;i++) {
			scn(store[i]);
			cnt[store[i]]++;
		}

		vector<long double>ps;
		for(LL i=0;i<10010;i++) {
			for(LL j=0;j<cnt[i]/2;j++)
				ps.push_back(i);
		}

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		double mind=INF;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			double diff = (ps[i+1]-ps[i])*(ps[i+1]-ps[i])/(ps[i]*ps[i+1]);
			if(diff<=mind) {
				mind=diff;
				mini=i;
			}
		}

		cout<<ps[mini]<<" "<<ps[mini]<<" "<<ps[mini+1]<<" "<<ps[mini+1]<<endl;

	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	while(tc--) {
		LL n;
		scn(n);

		LL store[n];
		for(LL i=0;i<n;i++)
			scn(store[i]);

		sort(store, store+n);

		vector<long double>ps;
		for(LL i=0;i<n;i++) {
			if(store[i]==store[i+1]) {
				ps.push_back(store[i]);
				i++;
			}
		}

		// sort(ps.begin(), ps.end());

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		bool finished = false;
		for(LL i=1;i<ps.size();i++){
			if(ps[i]==ps[i-1]) {
				cout<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<endl;
				finished = true;
				break;
			}
		}

		if(!finished) {
			double mind=INF;
			LL mini;
			for(LL i=0;i<ps.size()-1;i++) {
				// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
				if((ps[i+1]-ps[i])*(ps[i+1]-ps[i])/(ps[i]*ps[i+1])<=mind) {
					mind=(ps[i+1]-ps[i])*(ps[i+1]-ps[i])/(ps[i]*ps[i+1]);
					mini=i;
				}
			}

			cout<<ps[mini]<<" "<<ps[mini]<<" "<<ps[mini+1]<<" "<<ps[mini+1]<<endl;
		}
	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	while(tc--) {
		LL n;
		scn(n);

		LL store[n];
		for(LL i=0;i<n;i++)
			scn(store[i]);

		sort(store, store+n);

		vector<long double>ps;
		for(LL i=0;i<n;i++) {
			if(i<n && store[i]==store[i+1]) {
				ps.push_back(store[i]);
				i++;
			}
		}

		// sort(ps.begin(), ps.end());
		bool finished = false;
		for(LL i=1;i<ps.size();i++){
			if(ps[i]==ps[i-1]) {
				cout<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<endl;
				finished = true;
			}
		}

		if(!finished) {
			if(ps.size()%2==0) {
				// cout<<"here1"<<endl;
				cout<<ps[ps.size()/2]<<" "<<ps[ps.size()/2]<<" "<<ps[ps.size()/2-1]<<" "<<ps[ps.size()/2-1]<<endl;
			} else {
				LL x=ps.size()/2;
				if((ps[x]+ps[x-1])*(ps[x]+ps[x-1])/(ps[x]*ps[x-1]) < ((ps[x]+ps[x+1])*(ps[x]+ps[x+1]))/(ps[x]*ps[x+1])) {
					// cout<<"here2"<<endl;
					cout<<ps[x]<<" "<<ps[x]<<" "<<ps[x-1]<<" "<<ps[x-1]<<endl;
				} else {
					// cout<<"here3"<<endl;
					cout<<ps[x]<<" "<<ps[x]<<" "<<ps[x+1]<<" "<<ps[x+1]<<endl;
				}
			}
		}
	}
}


#include<bits/stdc++.h>

#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	LL cnt[10010];

	memset(cnt, 0, sizeof(cnt));

	while(tc--) {
		LL n;
		scn(n);

		LL tmp, mmax=0;
		for(LL i=0;i<n;i++) {
			scn(tmp);
			cnt[tmp]++;
			if(tmp>mmax)mmax=tmp;
		}

		vector<LL>ps;
		for(LL i=0;i<=mmax;i++) {
			for(LL j=0;j<cnt[i]/2 && j<2;j++)
				ps.push_back(i);
			cnt[i]=0;
		}

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		long double mind=INF, diff;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			diff = ((LD)(ps[i+1]+ps[i])*(LD)(ps[i+1]+ps[i]))/(LD)(ps[i]*ps[i+1]);
			if(diff<mind) {
				mind=diff;
				mini=i;
			}
			// cout<<"diff="<<diff<<endl;
		}

		// cout<<ps[mini],ps[mini],ps[mini+1],ps[mini+1]<<endl;
		printf("%lld %lld %lld %lld\n",ps[mini],ps[mini],ps[mini+1],ps[mini+1]);
	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	while(tc--) {
		LL n;
		scn(n);

		LL store[n];
		for(LL i=0;i<n;i++)
			scn(store[i]);

		sort(store, store+n);

		vector<long double>ps;
		for(LL i=0;i<n;i++) {
			if(i<n && store[i]==store[i+1]) {
				ps.push_back(store[i]);
				i++;
			}
		}

		// sort(ps.begin(), ps.end());
		bool finished = false;
		for(LL i=1;i<ps.size();i++){
			if(ps[i]==ps[i-1]) {
				cout<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<" "<<ps[i]<<endl;
				finished = true;
				break;
			}
		}

		if(!finished) {
			if(ps.size()%2==0) {
				// cout<<"here1"<<endl;
				cout<<ps[ps.size()/2]<<" "<<ps[ps.size()/2]<<" "<<ps[ps.size()/2-1]<<" "<<ps[ps.size()/2-1]<<endl;
			} else {
				LL x=ps.size()/2;
				if((ps[x]+ps[x-1])*(ps[x]+ps[x-1])/(ps[x]*ps[x-1]) < ((ps[x]+ps[x+1])*(ps[x]+ps[x+1]))/(ps[x]*ps[x+1])) {
					// cout<<"here2"<<endl;
					cout<<ps[x]<<" "<<ps[x]<<" "<<ps[x-1]<<" "<<ps[x-1]<<endl;
				} else {
					// cout<<"here3"<<endl;
					cout<<ps[x]<<" "<<ps[x]<<" "<<ps[x+1]<<" "<<ps[x+1]<<endl;
				}
			}
		}
	}
}


#include<bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1000000007
#define scn(a) scanf("%lld", &a)

using namespace std;

int main() {
	LL tc;
	scn(tc);
	LL cnt[10010];

	memset(cnt, 0, sizeof(cnt));

	while(tc--) {
		LL n;
		scn(n);

		LL tmp, mmax=0;
		for(LL i=0;i<n;i++) {
			scn(tmp);
			cnt[tmp]++;
			if(tmp>mmax)mmax=tmp;
		}

		vector<long double>ps;
		for(LL i=0;i<=mmax;i++) {
			for(LL j=0;j<cnt[i]/2 && j<2;j++)
				ps.push_back(i);
			cnt[i]=0;
		}

		// for(auto x:ps){
		// 	cout<<".."<<x<<endl;
		// }

		long double mind=INF;
		LL mini;
		for(LL i=0;i<ps.size()-1;i++) {
			// cout<<ps[i+1]<<"....."<<ps[i]<<endl;
			long double diff = (ps[i+1]+ps[i])*(ps[i+1]+ps[i])/(ps[i]*ps[i+1]);
			if(diff<mind) {
				mind=diff;
				mini=i;
			}
			// cout<<"diff="<<diff<<endl;
		}

		cout<<ps[mini]<<" "<<ps[mini]<<" "<<ps[mini+1]<<" "<<ps[mini+1]<<endl;

	}
}


#include<bits/stdc++.h>
typedef long long int ll;
typedef long double lf;
using namespace std;

int main(){

    ll t;
    cin>>t;

    while(t--){

        cout<<fixed<<setprecision(10);

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::reverse_iterator it , ii;

        ll mx = 1e18;

        pair< ll , ll > pr ;

        for(it = mp.rbegin() ; it != mp.rend() ; it++){

            if(it->second < 2){
                continue;
            }

            if( it->second >= 4 ){
                ll val = (ll) ( 4 * pow( (it->first + it->first), 2 ) ) / (ll)( (it->first) * (it->first) );

                if( val < mx ){
                    mx = val;
                    pr = make_pair( it->first , it->first );
                }
            }

            it++;

            if( it == mp.rend() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){
                ll val = (ll) ( 4 * pow( (it->first + ii->first), 2 ) ) / (ll)( (it->first) * (ii->first) );

                if( val < mx ){
                    mx = val;
                    pr = make_pair( it->first , ii->first );
                }

            }

        }

        cout<<pr.first<<" "<<pr.first<<" "<<pr.second<<" "<<pr.second<<endl;

    }

}


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

int main(){

    ll t;
    cin>>t;

    while(t--){

        cout<<fixed<<setprecision(10);

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::reverse_iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        for(it = mp.rbegin() ; it != mp.rend() ; it++){

            if(it->second < 2){
                continue;
            }

            if( it->second >= 4 ){
                double val = (double) ( 4 * pow( (it->first + it->first), 2 ) ) / (double)( (it->first) * (it->first) );
                v.push_back( make_pair( val , make_pair( it->first , it->first ) )  );

                break;
            }

            it++;

            if( it == mp.rend() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){
                double val = (double) ( 4 * pow( (it->first + ii->first), 2 ) ) / (double)( (it->first) * (ii->first) );
                v.push_back( make_pair( val , make_pair( it->first , ii->first ) )  );

                break;
            }

            if( v.size() == 10 ){
                break;
            }

        }

        map<ll,ll>::iterator itt , iii;

        vector< pair<  double , pair<ll,ll> >  > s;

        for(itt = mp.begin() ; itt != mp.end() ; it++){

            if(itt->second < 2){
                continue;
            }

            if( itt->second >= 4 ){
                double val = (double) ( 4 * pow( (itt->first + itt->first), 2 ) ) / (double)( (itt->first) * (itt->first) );
                s.push_back( make_pair( val , make_pair( itt->first , itt->first ) )  );

                break;
            }

            itt++;

            if( itt == mp.end() ){
                break;
            }

            iii = itt;

            itt--;

            if( itt->second > 1 && iii->second > 1 ){
                double val = (double) ( 4 * pow( (itt->first + iii->first), 2 ) ) / (double)( (itt->first) * (iii->first) );
                s.push_back( make_pair( val , make_pair( itt->first , iii->first ) )  );
            }

            if(s.size() == 10){
                break;
            }

        }

        sort( v.begin() , v.end() );
        sort( s.begin() , s.end() );

        pair< double , pair<ll,ll> > pr , pr2;

        pr = v[ 0 ];
        pr2 = s[ 0 ];

        if( pr.first < pr2.first ){
            cout<<pr.second.first<<" "<<pr.second.first<<" "<<pr.second.second<<" "<<pr.second.second<<endl;
        }else{
            cout<<pr2.second.first<<" "<<pr2.second.first<<" "<<pr2.second.second<<" "<<pr2.second.second<<endl;
        }

    }

}


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

int main(){

    ll t;
    cin>>t;

    while(t--){

        cout<<fixed<<setprecision(10);

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        for(it = mp.begin() ; it != mp.end() ; it++){

            if( it->second >= 4 ){
                double val = (double) ( 4 * pow( (it->first + it->first), 2 ) ) / (double)( (it->first) * (it->first) );
                v.push_back( make_pair( val , make_pair( it->first , it->first ) )  );

                break;
            }

            it++;

            if( it == mp.end() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){
                double val = (double) ( 4 * pow( (it->first + ii->first), 2 ) ) / (double)( (it->first) * (ii->first) );
                v.push_back( make_pair( val , make_pair( it->first , ii->first ) )  );

                break;
            }

        }

        pair< double , pair<ll,ll> > pr;

        pr = v[ 0 ];

        cout<<pr.second.first<<" "<<pr.second.first<<" "<<pr.second.second<<" "<<pr.second.second<<endl;

    }

}


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

int main(){

    ll t;
    cin>>t;

    while(t--){

        cout<<fixed<<setprecision(10);

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::reverse_iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        for(it = mp.rbegin() ; it != mp.rend() ; it++){

            if( it->second >= 4 ){
                double val = (double) ( 4 * pow( (it->first + it->first), 2 ) ) / (double)( (it->first) * (it->first) );
                v.push_back( make_pair( val , make_pair( it->first , it->first ) )  );

                break;
            }

            it++;

            if( it == mp.rend() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){
                double val = (double) ( 4 * pow( (it->first + ii->first), 2 ) ) / (double)( (it->first) * (ii->first) );
                v.push_back( make_pair( val , make_pair( it->first , ii->first ) )  );

                break;
            }

            if( v.size() == 2 ){
                break;
            }

        }

        map<ll,ll>::iterator itt , iii;

        vector< pair<  double , pair<ll,ll> >  > s;

        for(itt = mp.begin() ; itt != mp.end() ; it++){

            if( itt->second >= 4 ){
                double val = (double) ( 4 * pow( (itt->first + itt->first), 2 ) ) / (double)( (itt->first) * (itt->first) );
                s.push_back( make_pair( val , make_pair( itt->first , itt->first ) )  );

                break;
            }

            itt++;

            if( itt == mp.end() ){
                break;
            }

            iii = itt;

            itt--;

            if( itt->second > 1 && iii->second > 1 ){
                double val = (double) ( 4 * pow( (itt->first + iii->first), 2 ) ) / (double)( (itt->first) * (iii->first) );
                s.push_back( make_pair( val , make_pair( itt->first , iii->first ) )  );
            }

            if(s.size() == 2){
                break;
            }

        }

        sort( v.begin() , v.end() );
        sort( s.begin() , s.end() );

        pair< double , pair<ll,ll> > pr , pr2;

        pr = v[ 0 ];
        pr2 = s[ 0 ];

        if( pr.first < pr2.first ){
            cout<<pr.second.first<<" "<<pr.second.first<<" "<<pr.second.second<<" "<<pr.second.second<<endl;
        }else{
            cout<<pr2.second.first<<" "<<pr2.second.first<<" "<<pr2.second.second<<" "<<pr2.second.second<<endl;
        }

    }

}


#include<bits/stdc++.h>
typedef long long int ll;
typedef  long double lf;
using namespace std;

int main(){

    ll t;
    cin>>t;

    while(t--){

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        double mx = 1e10;

        ll num1 , num2;

        int flag = 0;

        for( it = mp.begin() ; it != mp.end() ; it++ ){

            if( it->second >= 4 ){
                cout<<it->first<<" "<<it->first<<" "<<it->first<<" "<<it->first<<endl;
                flag = 1;
                break;
            }

        }

        if( flag ){
            continue;
        }

        for(it = mp.begin() ; it != mp.end() ; it++){

            it++;

            if( it == mp.end() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){
                cout<<it->first<<" "<<it->first<<" "<<ii->first<<" "<<ii->first<<endl;
            }

        }

    }

}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin>>t;

    while(t--)
    {
    	int n , i;
    	cin>>n;

    	vector< int > v;
    	vector< int > final;

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

    		v.push_back(x);
    	}

    	sort(v.begin(),v.end());

    	for(i=0;i<v.size()-1;i++){
    		if(v[i]==v[i+1]){
    			final.push_back(v[i]);
    			i++;
    		}
    	}

    	int pos;

    	double minima=1000000000000000.0;

    	for(i=0;i<final.size()-1;i++){

    		double first=final[i];
    		double second=final[i+1];

    		double compute=(first/second) + (second/first);

    		if(compute < minima)
    		{
    			minima = compute;
    			pos=i;
    		}
    	}
    	cout<<final[pos]<<" "<<final[pos]<<" "<<final[pos+1]<<" "<<final[pos+1]<<endl;
    }

    return 0;
}


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

int main(){

    ll t;
    cin>>t;

    while(t--){

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        for(it = mp.begin() ; it != mp.end() ; it++){

            if( it->second >= 4 ){
                double val = (double) ( 4 * pow( (it->first + it->first), 2 ) ) / (double)( (it->first) * (it->first) );
                v.push_back( make_pair( val , make_pair( it->first , it->first ) )  );
            }

            it++;

            if( it == mp.end() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){
                double val = (double) ( 4 * pow( (it->first + ii->first), 2 ) ) / (double)( (it->first) * (ii->first) );
                v.push_back( make_pair( val , make_pair( it->first , ii->first ) )  );
            }

            if( v.size() >= 1 ){
                break;
            }

        }

        sort( v.begin() , v.end() );

        pair< double , pair<ll,ll> > pr;

        pr = v[ 0 ];

        cout<<pr.second.first<<" "<<pr.second.first<<" "<<pr.second.second<<" "<<pr.second.second<<endl;

    }

}


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

int main(){

    ll t;
    cin>>t;

    while(t--){

        cout<<fixed<<setprecision(10);

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::reverse_iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        for(it = mp.rbegin() ; it != mp.rend() ; it++){

            if( it->second >= 4 ){
                double val = (double) ( 4 * pow( (it->first + it->first), 2 ) ) / (double)( (it->first) * (it->first) );
                v.push_back( make_pair( val , make_pair( it->first , it->first ) )  );

                break;
            }

            it++;

            if( it == mp.rend() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){
                double val = (double) ( 4 * pow( (it->first + ii->first), 2 ) ) / (double)( (it->first) * (ii->first) );
                v.push_back( make_pair( val , make_pair( it->first , ii->first ) )  );

                break;
            }

        }

        pair< double , pair<ll,ll> > pr;

        pr = v[ 0 ];

        cout<<pr.second.first<<" "<<pr.second.first<<" "<<pr.second.second<<" "<<pr.second.second<<endl;

    }

}


#include<bits/stdc++.h>
typedef long long int ll;
typedef long double lf;
using namespace std;

int main(){

    ll t;
    cin>>t;

    while(t--){

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        lf mx = 1e18;

        ll num1 , num2;

        for(it = mp.begin() ; it != mp.end() ; it++){

            if( it->second >= 4 ){
                lf val = (lf)( 4 * pow( (it->first + it->first), 2 ) ) /(lf) ( (it->first) * (it->first) );

                if(val < mx){
                    mx = val;
                    num1 = it->first;
                    num2 = it->first;
                }

            }

            it++;

            if( it == mp.end() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){

                ll val =  ((lf) 4 * pow( (it->first + ii->first), 2 ) ) / (lf) ( (it->first) * (ii->first) );

                if(val < mx){
                    mx = val;
                    num1 = it->first;
                    num2 = ii->first;
                }

            }

        }

        cout<<num1<<" "<<num1<<" "<<num2<<" "<<num2<<endl;

    }

}


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

int main(){

    ll t;
    cin>>t;

    while(t--){

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        ll mx = 1e18;

        ll num1 , num2;

        for(it = mp.begin() ; it != mp.end() ; it++){

            if( it->second >= 4 ){
                ll val =  ( 4 * pow( (it->first + it->first), 2 ) ) / ( (it->first) * (it->first) );

                if(val < mx){
                    mx = val;
                    num1 = it->first;
                    num2 = it->first;
                }

            }

            it++;

            if( it == mp.end() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){

                ll val =  ( 4 * pow( (it->first + ii->first), 2 ) ) / ( (it->first) * (ii->first) );

                if(val < mx){
                    mx = val;
                    num1 = it->first;
                    num2 = ii->first;
                }

            }

        }

        cout<<num1<<" "<<num1<<" "<<num2<<" "<<num2<<endl;

    }

}


#include<bits/stdc++.h>
typedef long long int ll;
typedef  long double lf;
using namespace std;

int main(){

    ll t;
    cin>>t;

    while(t--){

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        double mx = 1e10;

        ll num1 , num2;

        for(it = mp.begin() ; it != mp.end() ; it++){

            if( it->second >= 4 ){

                lf val = (lf)( 4 * pow( (it->first + it->first), 2 ) ) /(lf) ( (it->first) * (it->first) );

                if(val < mx){
                    mx = val;
                    num1 = it->first;
                    num2 = it->first;
                }

            }

            it++;

            if( it == mp.end() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){

                lf val =  (lf) ( 4 * pow( (it->first + ii->first), 2 ) ) / (lf) ( (it->first) * (ii->first) );

                if(val < mx){
                    mx = val;
                    num1 = it->first;
                    num2 = ii->first;
                }

            }

        }

        cout<<num1<<" "<<num1<<" "<<num2<<" "<<num2<<endl;

    }

}


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

int main(){

    ll t;
    cin>>t;

    while(t--){

        cout<<fixed<<setprecision(10);

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::reverse_iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        for(it = mp.rbegin() ; it != mp.rend() ; it++){

            if( it->second >= 4 ){
                double val = (double) ( 4 * pow( (it->first + it->first), 2 ) ) / (double)( (it->first) * (it->first) );
                v.push_back( make_pair( val , make_pair( it->first , it->first ) )  );

                break;
            }

            it++;

            if( it == mp.rend() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){
                double val = (double) ( 4 * pow( (it->first + ii->first), 2 ) ) / (double)( (it->first) * (ii->first) );
                v.push_back( make_pair( val , make_pair( it->first , ii->first ) )  );

                break;
            }

        }

        map<ll,ll>::iterator itt , iii;

        vector< pair<  double , pair<ll,ll> >  > s;

        for(itt = mp.begin() ; itt != mp.end() ; it++){

            if( itt->second >= 4 ){
                double val = (double) ( 4 * pow( (itt->first + itt->first), 2 ) ) / (double)( (itt->first) * (itt->first) );
                s.push_back( make_pair( val , make_pair( itt->first , itt->first ) )  );

                break;
            }

            itt++;

            if( itt == mp.end() ){
                break;
            }

            iii = itt;

            itt--;

            if( itt->second > 1 && iii->second > 1 ){
                double val = (double) ( 4 * pow( (itt->first + iii->first), 2 ) ) / (double)( (itt->first) * (iii->first) );
                s.push_back( make_pair( val , make_pair( itt->first , iii->first ) )  );

                break;
            }

        }

        pair< double , pair<ll,ll> > pr , pr2;

        pr = v[ 0 ];
        pr2 = s[ 0 ];

        if( pr.first < pr2.first ){
            cout<<pr.second.first<<" "<<pr.second.first<<" "<<pr.second.second<<" "<<pr.second.second<<endl;
        }else{
            cout<<pr2.second.first<<" "<<pr2.second.first<<" "<<pr2.second.second<<" "<<pr2.second.second<<endl;
        }

    }

}


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

int main(){

    ll t;
    cin>>t;

    while(t--){

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        for(it = mp.begin() ; it != mp.end() ; it++){

            if( it->second >= 4 ){
                double val = (double) ( 2*(it->first + it->first) ) / (double)( (it->first) * (it->first) );
                v.push_back( make_pair( val , make_pair( it->first , it->first ) )  );
            }

            it++;

            if( it == mp.end() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){
                double val = (double) ( 2*(it->first + ii->first) ) / (double)( (it->first) * (ii->first) );
                v.push_back( make_pair( val , make_pair( it->first , ii->first ) )  );
            }

        }

        sort( v.begin() , v.end() );

        pair< double , pair<ll,ll> > pr;

        pr = v[ 0 ];

        cout<<pr.second.first<<" "<<pr.second.first<<" "<<pr.second.second<<" "<<pr.second.second<<endl;

    }

}


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

int main(){

    ll t;
    cin>>t;

    while(t--){

        ll n , i;
        cin>>n;

        ll a[n];

        map<ll,ll> mp;

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

        map<ll,ll>::iterator it , ii;

        vector< pair<  double , pair<ll,ll> >  > v;

        for(it = mp.begin() ; it != mp.end() ; it++){

            if( it->second >= 4 ){
                double val = (double) ( 4 * pow( (it->first + it->first), 2 ) ) / (double)( (it->first) * (it->first) );
                v.push_back( make_pair( val , make_pair( it->first , it->first ) )  );
            }

            it++;

            if( it == mp.end() ){
                break;
            }

            ii = it;

            it--;

            if( it->second > 1 && ii->second > 1 ){
                double val = (double) ( 4 * pow( (it->first + ii->first), 2 ) ) / (double)( (it->first) * (ii->first) );
                v.push_back( make_pair( val , make_pair( it->first , ii->first ) )  );
            }

        }

        sort( v.begin() , v.end() );

        pair< double , pair<ll,ll> > pr;

        pr = v[ 0 ];

        cout<<pr.second.first<<" "<<pr.second.first<<" "<<pr.second.second<<" "<<pr.second.second<<endl;

    }

}


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

int main()
{
    int t;
    cin>>t;

    while(t--)
    {
    	int n , i;
    	cin>>n;

    	vector< int > v;
    	vector< int > final;

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

    		v.push_back(x);
    	}

    	sort(v.begin(),v.end());

    	for(i=0;i<v.size()-1;i++){
    		if(v[i]==v[i+1]){
    			final.push_back(v[i]);
    			i++;
    		}
    	}

    	int pos;

    	double minima=1000000000000000.0;

    	for(i=0;i<final.size()-1;i++){

    		double first=final[i];
    		double second=final[i+1];

    		double compute=(first/second) + (second/first);

    		if(compute < minima)
    		{
    			minima = compute;
    			pos=i;
    		}
    	}
    	cout<<final[pos]<<" "<<final[pos]<<" "<<final[pos+1]<<" "<<final[pos+1]<<endl;
    }

    return 0;
}


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

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<int>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		int mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (arr0[i] - arr0[i - 1] <= mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = arr0[i] - arr0[i - 1];
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


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

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<double>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		double mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (arr0[i] / arr0[i - 1] < mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = arr0[i] - arr0[i - 1];
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


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

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<int>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		int mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (arr0[i] / arr0[i - 1] - arr0[i - 1] / arr0[i] < mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = arr0[i] / arr0[i - 1] - arr0[i - 1] / arr0[i];
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


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

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<long long>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		long long mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (arr0[i] / arr0[i - 1] + arr0[i - 1] / arr0[i] <= mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = arr0[i] / arr0[i - 1] + arr0[i - 1] / arr0[i] ;
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


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

long long fn(long long a, long long b) {
	long long P = a * b;
	long long S = a + b;
	return S * S / P;
}

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<int>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		int mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (fn(arr0[i], arr0[i - 1]) < mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = fn(arr0[i], arr0[i - 1]);
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


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

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<int>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		double mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (arr0[i] / arr0[i - 1] + arr0[i - 1] / arr0[i] < mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = arr0[i] - arr0[i - 1];
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


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

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<long long>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		long long mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (arr0[i] / arr0[i - 1] + arr0[i - 1] / arr0[i] <= mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = arr0[i] - arr0[i - 1];
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


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

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<long long>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		long long mn = 1e5;
		for (int i = 1; i < n; i++) {
			long long A = arr0[i], B = arr0[i - 1];
			if (((A + B) * (A + B)) / (A * B) <= mn) {
				x = A;
				y = B;
				mn = ((A + B) * (A + B)) / (A * B)  ;
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


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

double fn(double a, double b) {
	double P = a * b;
	double S = a + b;
	return S * S / P;
}

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<int>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		double mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (fn(arr0[i], arr0[i - 1]) < mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = fn(arr0[i], arr0[i - 1]);
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;
	}
	return 0;
}

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


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

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<double>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		double mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (arr0[i] / arr0[i - 1] + arr0[i - 1] / arr0[i] < mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = arr0[i] - arr0[i - 1];
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


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

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<int>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		int mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (arr0[i] - arr0[i - 1] < mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = arr0[i] - arr0[i - 1];
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


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

void RED();
int main() {
	RED();

	int T;
	cin >> T;
	while (T--) {
		int64_t n;
		cin >> n;
		int arr[n];
		for (int64_t i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + n);

		vector<double>arr0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] == arr[i]) {
				arr0.push_back(arr[i]);
				i++;
			}
		}
		n = arr0.size();
		int x, y;
		double mn = 1e5;
		for (int i = 1; i < n; i++) {
			if (arr0[i] / arr0[i - 1] + arr0[i - 1] / arr0[i] < mn) {
				x = arr0[i];
				y = arr0[i - 1];
				mn = arr0[i] / arr0[i - 1] + arr0[i - 1] / arr0[i];
			}
		}
		cout << x << " " << x << " " << y << " " << y << endl;

	}
	return 0;
}

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


//In the name of Allah
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(ll i=a;i<b;i++)
#define Forr(i,a,b) for(ll i=a;i>=b;i--)
#define all(v)     (v).begin(),(v).end()
#define sz(v)      (ll) (v).size()
#define ll  long long
#define clr(a,val) memset(a,val,sizeof(a))
#define d(x) {cerr <<#x <<" = " <<x <<endl;}
#define pf printf
#define sc scanf
#define C (ll)
#define pii pair<ll,ll>
ll oo = (ll)1e9;
template<typename T> using V = vector<T>;
inline void fastInOut() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
    fastInOut();
    string s;
    ll k;
    cin >> k >> s;
    V<int>on;
    For(i, 0, sz(s)) {
        if(s[i] == '1')
            on.push_back(i);
    }
    ll ans = 0;
    if (sz(on) < k) {
        cout << 0;
        return 0;
    }
    if (!k) {
        ans += on[0]+on[0]-1;
        For(i, 1, sz(on)){
            ans += on[i] - on[i - 1] - 3 + on[i] - on[i - 1] ;
        }
        d(ans);
        ans += sz(s) - 1 - on[sz(on) - 1];
        cout << ans;
        return 0;
    }
    ll l = 0, r = 0, ret = 0;
    For(i, 0, sz(on)) {
        l = i, r = i + k - 1;
        if (r >= sz(on))
            break;
        if (l - 1 < 0)
            ans += on[l];
        else
            ans += on[l] - on[l - 1] - 1;
        if (r + 1 >= sz(on))
            ans += sz(s) - 1 - on[r];
        else
            ans += on[r + 1] - on[r] - 1;
        d(ans);

        ret += ans * 2;
        ans = 0;
    }
    cout << ret;
    return 0;
}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define sz(a) ((int)a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

void sc(int &a) { scanf("%d", &a); }void sc(ll &a) { scanf("%lld", &a); }void sc(int& a, int& b) { sc(a); sc(b); }
void sc(ll &a, ll &b) { sc(a); sc(b); }void sc(int& a, int& b, int& c) { sc(a, b); sc(c); }void sc(ll& a, ll& b, ll& c) { sc(a, b); sc(c); }
void prl(int a) { printf("%d\n", a); }void prl(ll a) { printf("%lld\n", a); }void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }void prs(ll a) { printf("%lld ", a); }

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

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

ll poww(ll a, ll b) {

	if (b == 0) return 1;

	ll tmp = poww(a, b / 2);

	return (b & 1 ? a * tmp * tmp : tmp * tmp);

}

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

string itos(ll i) { string s = ""; 	while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s));  return s; }

ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); }  return tot; }

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI acos((ld)-1.0)

void tt() {

#ifndef online	_judge
	freopen("test.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

#endif
}

// printf("%.8lf\n", sum * 1.0 / n);  // precision setting

ll mod = 1000000000000000003;

ll modpower(ll x, ll y, ll p)
{

	x %= mod;

	if (!y) return 1;

	ll res = 1;

	if (y & 1) { res *= x;  res %= p; }

	ll z = modpower(x, y / 2, p);

	z %= p;

	z *= z;

	z %= mod;

	res *= z;

	res %= p;

	return res;

}

int a[1000 * 1000], pre[1000 * 1000];

int main() {

	int k;
	cin >> k;

	string s;
	cin >> s;

	int n = (int)s.length();

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

		pre[i] = pre[i - 1] + s[i - 1] - '0';

	}

	if (k == 0) {

		ll tot = 0;

		for (int i = 0; i < (int)s.length(); i++) {

			if (s[i] == '0') {

				ll cnt = 0;
				while (i < (int)s.length() && s[i] == '0') { i++; cnt++;  }

				tot += (cnt * (cnt + 1)) / 2;

			}

		}

		return cout << tot << endl, 0;
	}

	ll tot = 0;

	int l = 1;

	/*for (int i = 1; i <= n; i++) cout << pre[i] << " ";
	cout << endl; */

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

		int req = k + pre[i - 1];

		//cout << "i: " << i << " req: " << req << endl;
/*
		int u = upper_bound(pre + 1, pre + n + 1, req) - pre - 1;

		int l = lower_bound(pre + 1, pre + n + 1, req) - pre- 1;
		*/
		ll cnt = upper_bound(pre + 1, pre + n + 1, req) - lower_bound(pre + 1, pre + n + 1, req);

		tot += cnt;
		//cout << "u: " << u << " l: " << l << endl;

		//tot += cnt;

	}

	cout << tot << endl;

	return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

ll stoi(string &str) { istringstream ss(str); ll i; ss >> i;  return i; }

string itos(ll i) { stringstream ss; ss << i;   return ss.str(); }

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

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

ll poww(ll a, ll b) { ll res = 1;   for (int i = 1; i <= b; i++) res *= a;  return res; }

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

ll mod = poww(10, 9) + 7;

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI 3.14159265358979323846

void t(){

#ifndef online_judge
	freopen("test.txt", "r", stdin);
#endif
}

int a[1000001], sp[10000001], ep[1000001];

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0);
	fill(sp, sp + 1000001, -1);
	fill(ep, ep + 1000001, -1);

	int k;
	cin >> k;
	string s;
	cin >> s;
	a[0] = (s[0] == '0' ? 0 : 1);

	if (k == 0) {
		ll cnt = 0;
		int i = 0, j = 0;
		for ( ; i < s.length(); i++) {

			if (s[i] == '1') {

				ll x = (i - j);
				cnt += (x * (x + 1)) / 2;
				j = i + 1;

			}
		}

		cnt += ((i - j) * ( i - j + 1))/2;
		//cout << "cnt: " << cnt << endl;
		return cout << cnt << endl, 0;
	}

	for (int i = 1; i < s.length(); i++) {

		a[i] = (s[i] == '0' ? a[i - 1] : a[i - 1] + 1);

	}

	for (int i = 0; i < (int)s.length() ; i++) {

		if (sp[a[i]] == -1) sp[a[i]] = i;
		else sp[a[i]] = min(i, sp[a[i]]);

		ep[a[i]] = max(ep[a[i]], i);

	}

	ll cnt = 0;

	for (int i = 0; i < s.length(); i++) {

		if (s[i] == '0') {

			int st = sp[a[i] + k];
			if (st == -1) continue;

			int ed = ep[a[i] + k];

			if (st > ed) continue;
			cnt += ed - st + 1;

		}

		 else if (s[i] == '1') {
			if (k == 0) continue;

			int st = sp[a[i] + k - 1];
			if (st == -1) continue;

			int ed = ep[a[i] + k - 1];
			if (st > ed) continue;
			cnt += ed - st + 1;

		}
	}

	cout << cnt << endl;
	return 0;

}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

ll stoi(string &str) { istringstream ss(str); ll i; ss >> i;  return i; }

string itos(ll i) { stringstream ss; ss << i;   return ss.str(); }

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

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

ll poww(ll a, ll b) { ll res = 1;   for (int i = 1; i <= b; i++) res *= a;  return res; }

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

ll mod = poww(10, 9) + 7;

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI 3.14159265358979323846

void t(){

#ifndef online_judge
	freopen("test.txt", "r", stdin);
#endif
}

int a[1000001], sp[10000001], ep[1000001];

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0);
	fill(sp, sp + 1000001, -1);
	fill(ep, ep + 1000001, -1);

	int k;
	cin >> k;
	string s;
	cin >> s;
	a[0] = (s[0] == '0' ? 0 : 1);
	for (int i = 1; i < s.length(); i++) {

		a[i] = (s[i] == '0' ? a[i - 1] : a[i - 1] + 1);

	}

	/*for (int i = 0; i < s.length(); i++) cout << a[i] << " ";
	cout << endl;*/

	for (int i = 0; i < (int)s.length() ; i++) {

		if (sp[a[i]] == -1) sp[a[i]] = i;
		else sp[a[i]] = min(i, sp[a[i]]);

		ep[a[i]] = max(ep[a[i]], i);

	}

	/*for (int i = 0; i <= 5; i++) cout << sp[i] << " ";
	cout << endl;
	for (int i = 0; i <= 5; i++) cout << ep[i] << " ";
	cout << endl;
	*/ll cnt = 0;
	for (int i = 0; i < s.length(); i++) {

		if (s[i] == '0') {

			int st = sp[a[i] + k];
			if (st == -1) continue;

			int ed = ep[a[i] + k];

			if (st > ed) continue;

			cnt += ed - st + 1;

		}

		else if (s[i] == '1') {
			if (k == 0) continue;

			int st = sp[a[i] + k - 1];
			if (st == -1) continue;

			int ed = ep[a[i] + k - 1];
			if (st > ed) continue;
			cnt += ed - st + 1;

		}
	}

	cout << cnt << endl;
	return 0;

}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define sz(a) ((int)a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

void sc(int &a) { scanf("%d", &a); }void sc(ll &a) { scanf("%lld", &a); }void sc(int& a, int& b) { sc(a); sc(b); }
void sc(ll &a, ll &b) { sc(a); sc(b); }void sc(int& a, int& b, int& c) { sc(a, b); sc(c); }void sc(ll& a, ll& b, ll& c) { sc(a, b); sc(c); }
void prl(int a) { printf("%d\n", a); }void prl(ll a) { printf("%lld\n", a); }void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }void prs(ll a) { printf("%lld ", a); }

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

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

ll poww(ll a, ll b) {

	if (b == 0) return 1;

	ll tmp = poww(a, b / 2);

	return (b & 1 ? a * tmp * tmp : tmp * tmp);

}

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

string itos(ll i) { string s = ""; 	while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s));  return s; }

ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); }  return tot; }

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI acos((ld)-1.0)

void tt() {

#ifndef online	_judge
	freopen("test.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

#endif
}

// printf("%.8lf\n", sum * 1.0 / n);  // precision setting

ll mod = 1000000000000000003;

ll modpower(ll x, ll y, ll p)
{

	x %= mod;

	if (!y) return 1;

	ll res = 1;

	if (y & 1) { res *= x;  res %= p; }

	ll z = modpower(x, y / 2, p);

	z %= p;

	z *= z;

	z %= mod;

	res *= z;

	res %= p;

	return res;

}

int a[1000 * 1000], pre[1000 * 1000];

int main() {

	int k;
	cin >> k;

	string s;
	cin >> s;

	int n = (int)s.length();

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

		pre[i] = pre[i - 1] + s[i - 1] - '0';

	}

	if (k == 0) {

		int tot = 0;

		for (int i = 0; i < (int)s.length(); i++) {

			if (s[i] == '0') {

				int cnt = 0;
				while (i < (int)s.length() && s[i] == '0') { i++; cnt++;  }

				tot += (cnt * (cnt + 1)) / 2;

			}

		}

		return cout << tot << endl, 0;
	}

	int tot = 0;

	int l = 1;

	/*for (int i = 1; i <= n; i++) cout << pre[i] << " ";
	cout << endl; */

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

		int req = k + pre[i - 1];

		//cout << "i: " << i << " req: " << req << endl;
/*
		int u = upper_bound(pre + 1, pre + n + 1, req) - pre - 1;

		int l = lower_bound(pre + 1, pre + n + 1, req) - pre- 1;
		*/
		int cnt = upper_bound(pre + 1, pre + n + 1, req) - lower_bound(pre + 1, pre + n + 1, req);

		tot += cnt;
		//cout << "u: " << u << " l: " << l << endl;

		//tot += cnt;

	}

	cout << tot << endl;

	return 0;
}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define sz(a) ((int)a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

void sc(int &a) { scanf("%d", &a); }void sc(ll &a) { scanf("%lld", &a); }void sc(int& a, int& b) { sc(a); sc(b); }
void sc(ll &a, ll &b) { sc(a); sc(b); }void sc(int& a, int& b, int& c) { sc(a, b); sc(c); }void sc(ll& a, ll& b, ll& c) { sc(a, b); sc(c); }
void prl(int a) { printf("%d\n", a); }void prl(ll a) { printf("%lld\n", a); }void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }void prs(ll a) { printf("%lld ", a); }

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

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

ll poww(ll a, ll b) {

	if (b == 0) return 1;

	ll tmp = poww(a, b / 2);

	return (b & 1 ? a * tmp * tmp : tmp * tmp);

}

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

string itos(ll i) { string s = ""; 	while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s));  return s; }

ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); }  return tot; }

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI acos((ld)-1.0)

void tt() {

#ifndef online	_judge
	freopen("test.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

#endif
}

// printf("%.8lf\n", sum * 1.0 / n);  // precision setting

ll mod = 1000000000000000003;

ll modpower(ll x, ll y, ll p)
{

	x %= mod;

	if (!y) return 1;

	ll res = 1;

	if (y & 1) { res *= x;  res %= p; }

	ll z = modpower(x, y / 2, p);

	z %= p;

	z *= z;

	z %= mod;

	res *= z;

	res %= p;

	return res;

}

int a[1000 * 1000], pre[1000 * 1000];

int main() {

	int k;
	cin >> k;

	string s;
	cin >> s;

	int n = (int)s.length();

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

		pre[i] = pre[i - 1] + s[i - 1] - '0';

	}

	int tot = 0;

	int l = 1;

	/*for (int i = 1; i <= n; i++) cout << pre[i] << " ";
	cout << endl; */

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

		int req = k + pre[i - 1];

		//cout << "i: " << i << " req: " << req << endl;
/*
		int u = upper_bound(pre + 1, pre + n + 1, req) - pre - 1;

		int l = lower_bound(pre + 1, pre + n + 1, req) - pre- 1;
		*/
		int cnt = upper_bound(pre + 1, pre + n + 1, req) - lower_bound(pre + 1, pre + n + 1, req);

		tot += cnt;
		//cout << "u: " << u << " l: " << l << endl;

		//tot += cnt;

	}

	cout << tot << endl;

	return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

ll stoi(string &str) { istringstream ss(str); ll i; ss >> i;  return i; }

string itos(ll i) { stringstream ss; ss << i;   return ss.str(); }

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

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

ll poww(ll a, ll b) { ll res = 1;   for (int i = 1; i <= b; i++) res *= a;  return res; }

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

ll mod = poww(10, 9) + 7;

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI 3.14159265358979323846

void t(){

#ifndef online_judge
	freopen("test.txt", "r", stdin);
#endif
}

int a[1000001], sp[10000001], ep[1000001];

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0);
	fill(sp, sp + 1000000, -1);
	fill(ep, ep + 1000000, -1);

	int k;
	cin >> k;
	string s;
	cin >> s;
	a[0] = (s[0] == '0' ? 0 : 1);
	for (int i = 1; i < s.length(); i++) {

		a[i] = (s[i] == '0' ? a[i - 1] : a[i - 1] + 1);

	}

	/*for (int i = 0; i < s.length(); i++) cout << a[i] << " ";
	cout << endl;*/

	for (int i = 0; i <= (int)s.length() - 1; i++) {

		if (sp[a[i]] == -1) sp[a[i]] = i;
		else sp[a[i]] = min(i, sp[a[i]]);

		ep[a[i]] = max(ep[a[i]], i);

	}

	/*for (int i = 0; i <= 5; i++) cout << sp[i] << " ";
	cout << endl;
	for (int i = 0; i <= 5; i++) cout << ep[i] << " ";
	cout << endl;
	*/ll cnt = 0;
	for (int i = 0; i < s.length(); i++) {

		if (s[i] == '0') {

			int st = sp[a[i] + k];
			if (st == -1) continue;

			int ed = ep[a[i] + k];
			cnt += ed - st + 1;

		}

		else if (s[i] == '1') {

			int st = sp[a[i] + k - 1];
			if (st == -1) continue;

			int ed = ep[a[i] + k - 1];

			cnt += ed - st + 1;

		}
	}

	cout << cnt << endl;
	return 0;

}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

ll stoi(string &str) { istringstream ss(str); ll i; ss >> i;  return i; }

string itos(ll i) { stringstream ss; ss << i;   return ss.str(); }

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

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

ll poww(ll a, ll b) { ll res = 1;   for (int i = 1; i <= b; i++) res *= a;  return res; }

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

ll mod = poww(10, 9) + 7;

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI 3.14159265358979323846

void t(){

#ifndef online_judge
	freopen("test.txt", "r", stdin);
#endif
}

int a[1000001], sp[10000001], ep[1000001];

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0);
	fill(sp, sp + 1000001, -1);
	fill(ep, ep + 1000001, -1);

	int k;
	cin >> k;
	string s;
	cin >> s;
	a[0] = (s[0] == '0' ? 0 : 1);

	if (k == 0) {
		ll cnt = 0;
		int i = 0, j = 0;
		for ( ; i < s.length(); i++) {

			if (s[i] == '1') {

				ll x = (i - j);
				cnt += (x * (x + 1)) / 2;
				j = i + 1;

			}
		}

		cnt += (ll(i - j) * ll( i - j + 1))/2ll;
		//cout << "cnt: " << cnt << endl;
		return cout << cnt << endl, 0;
	}

	for (int i = 1; i < s.length(); i++) {

		a[i] = (s[i] == '0' ? a[i - 1] : a[i - 1] + 1);

	}

	for (int i = 0; i < (int)s.length() ; i++) {

		if (sp[a[i]] == -1) sp[a[i]] = i;
		else sp[a[i]] = min(i, sp[a[i]]);

		ep[a[i]] = max(ep[a[i]], i);

	}

	ll cnt = 0;

	for (int i = 0; i < s.length(); i++) {

		if (s[i] == '0') {

			int st = sp[a[i] + k];
			if (st == -1) continue;

			int ed = ep[a[i] + k];

			if (st > ed) continue;
			cnt += ed - st + 1;

		}

		 else if (s[i] == '1') {
			if (k == 0) continue;

			int st = sp[a[i] + k - 1];
			if (st == -1) continue;

			int ed = ep[a[i] + k - 1];
			if (st > ed) continue;
			cnt += ed - st + 1;

		}
	}

	cout << cnt << endl;
	return 0;

}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin >> k;
    string s;
    cin >> s;
    vector<long long> cnt(s.size() + 1, 0);
    long long sum = 0, ans = 0;
    cnt[0] = 1;
    for (int i = 0; i < s.size(); ++i) {
        sum += s[i] == '1';
        if (sum >= k)
            ans += cnt[sum - k];
        cnt[sum]++;
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2;
char c[N];
int a[N] = {};
long long sum = 0;
void solve(int x,int y){
	sum += (a[y] - a[y - 1]) * (a[0] + 1);
	for(int i = y + 1; i <= x; i++){
		sum += ((a[i] - a[i - 1]) * (a[i - y] - a[i - y - 1]));}
}
int main(){

	int n;
	scanf("%d",&n);
	scanf("%s",&c);
	int len = strlen(c);
	int id = 0;
	for(int i = 0; i < len; i++)
		if(c[i] - '0' == 1) {a[id] = i; id++;}
	a[id] = len;
	if(id < n) printf("0\n");
	else if(id == n){ printf("%I64d\n",1ll * (a[id] - a[id - 1]) * (a[0] + 1));}
	else {solve(id,n); printf("%I64d\n",sum);}
}


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

vector<int> vec;

long long fact (int x) {
	return (x + 1) * x / 2;
}

int main() {
//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int k; string s; cin >> k >> s;
	s.push_back('1');
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') vec.push_back(i);
	}
	if (!k) {
		long long ans = fact(vec[0]);
		for (int i = 1; i < vec.size(); i++) {
			ans += fact(vec[i] - vec[i - 1] - 1);
		}
		cout << ans << endl;
	} else {
		if (vec.size() < k + 1) return cout << 0 << endl, 0;
		long long ans = 1ll * (vec[0] + 1) * (vec[k] - vec[k - 1]);
		for (int i = 1; i < vec.size() - k; i++) {
			ans += 1ll * (vec[i] - vec[i - 1]) * (vec[i + k] - vec[i + k - 1]);
		}
		cout << ans << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
char c[N];
int a[N] = {};
long long res = 0;

void solve(int x,int y){
    res += (a[y] - a[y - 1]) * (a[0] + 1);
    for(int i = y + 1; i <= x; i++){
        res += ((a[i] - a[i - 1]) * (a[i - y + 1] - a[i - y]));}
}

int main(){

    int n;
    scanf("%d",&n);
    scanf("%s",&c);
    int len = strlen(c);
    int id = 0;
    for(int i = 0; i < len; i++)
        if(c[i] - '0' == 1) {a[id] = i; id++;}
    a[id] = len;
    if(id < n) cout << 0 << endl;
    else if(id == n){ res=(a[id] - a[id - 1])*(a[0] + 1); cout << res << endl;}
    else {solve(id,n); cout << res << endl;}
}


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

vector<int> vec;

long long fact (int x) {
	return 1ll * (x + 1) * x / 2;
}

int main() {
//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int k; string s; cin >> k >> s;
	s.push_back('1');
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') vec.push_back(i);
	}
	if (!k) {
		long long ans = fact(vec[0]);
		for (int i = 1; i < vec.size(); i++) {
			ans += fact(vec[i] - vec[i - 1] - 1);
		}
		cout << ans << endl;
	} else {
		if (vec.size() < k + 1) return cout << 0 << endl, 0;
		long long ans = 1ll * (vec[0] + 1) * (vec[k] - vec[k - 1]);
		for (int i = 1; i < vec.size() - k; i++) {
			ans += 1ll * (vec[i] - vec[i - 1]) * (vec[i + k] - vec[i + k - 1]);
		}
		cout << ans << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector < long long > v;

int main() {
	string s;
	long long res, k;
	cin >> k;
	cin >> s;
	for(int i = 0; i < s.size();  i ++)
		if(s[i] == '1')v.push_back(i + 1);
	if(v.size() < k){cout << 0; return 0;}
	if(v.size() == k){
		cout << (s.size() - v[k - 1] + 1) * v[0];
		return 0;
	}
	res = v[0] * (v[k] - v[k -1]);
	for(int i = k; i < v.size() - 1; i ++){
		res += (v[i - k + 1] - v[i - k ]) * (v[i] - v[i - 1]);
	}
	res += (s.size() - v[v.size() - 1] + 1) * (v[v.size() - k] - v[v.size() - k - 1]);
	cout << res;
}


    #include <bits/stdc++.h>
using namespace std;
#define N 1000010
typedef long long ll;
char s[N];
vector<int> v;
int main(){
    int k;
    scanf("%d", &k);
    scanf("%s", s);
    ll ans = 0;
    int len = strlen(s);
    if(k == 0){
        ans = 1ll * (1 + len) * len / 2;
        cout << ans;
        return 0;
    }
    for(int i = 0; i < len; i ++){
        if(s[i] == '1') v.push_back(i);
    }

    for(int i = 0; i < v.size(); i ++){
        int st = i;
        int en = i + k - 1;
        if(en >= v.size()) break;
        int l , r;
        if(st == 0) l = v[st] - 0;
        else l = v[st] - v[st - 1] - 1;
        if(en == v.size() - 1) r = len - 1 -  v[en];
        else r = v[en + 1] - v[en] - 1;
        ans += 1ll * (l + 1) * (r + 1);
    }
    cout << ans;
}