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

int main(){
vector<int>a;
int n,s=0,b=0;long sum=0;
cin>>n;int nnn;
if(n>0){
	for(int i=0;i<n;i++){cin>>nnn;a.push_back(nnn);}
		 s=a[0],b=a[0];
		for(int i=0;i<a.size();i++){
			sum+=a[i];
			b=max(b,a[i]);
			s=min(s,a[i]);
		}
	cout<<s<<" "<<b<<" "<<sum<<endl;
		}
	else{
		printf("%d %d %d\n",s,b,sum);
		}
return 0;
}
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;

int partition(int A[], int p, int last){
  int x = A[last];
  int bigger_first_ind = p - 1;
  for(int j = p; j < last; j++){
    if(A[j] <= x) swap(A[++bigger_first_ind], A[j]);
  }
  swap(A[++bigger_first_ind], A[last]);
  return bigger_first_ind;
}

int main(){
  int n;
  cin >> n;
  int* A; A = new int[n];
  for(int i = 0; i < n; i++) cin >> A[i];
  int border = partition(A, 0, n-1);

  for(int i = 0; i < n-1; i++){
    if(i == border){
      cout << "[" << A[i] << "] ";
    }else
      cout << A[i] << " ";
  }
  cout << A[n-1] << endl;
}