#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

uint64 bitmaskr[64] = { 0xFFFFFFFFFFFFFFFE, 0xFFFFFFFFFFFFFFFC, 0xFFFFFFFFFFFFFFF8, 0xFFFFFFFFFFFFFFF0, 0xFFFFFFFFFFFFFFE0, 0xFFFFFFFFFFFFFFC0, 0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFF00, 0xFFFFFFFFFFFFFE00, 0xFFFFFFFFFFFFFC00, 0xFFFFFFFFFFFFF800, 0xFFFFFFFFFFFFF000, 0xFFFFFFFFFFFFE000, 0xFFFFFFFFFFFFC000, 0xFFFFFFFFFFFF8000, 0xFFFFFFFFFFFF0000, 0xFFFFFFFFFFFE0000, 0xFFFFFFFFFFFC0000, 0xFFFFFFFFFFF80000, 0xFFFFFFFFFFF00000, 0xFFFFFFFFFFE00000, 0xFFFFFFFFFFC00000, 0xFFFFFFFFFF800000, 0xFFFFFFFFFF000000, 0xFFFFFFFFFE000000, 0xFFFFFFFFFC000000, 0xFFFFFFFFF8000000, 0xFFFFFFFFF0000000, 0xFFFFFFFFE0000000, 0xFFFFFFFFC0000000, 0xFFFFFFFF80000000, 0xFFFFFFFF00000000, 0xFFFFFFFE00000000, 0xFFFFFFFC00000000, 0xFFFFFFF800000000, 0xFFFFFFF000000000, 0xFFFFFFE000000000, 0xFFFFFFC000000000, 0xFFFFFF8000000000, 0xFFFFFF0000000000, 0xFFFFFE0000000000, 0xFFFFFC0000000000, 0xFFFFF80000000000, 0xFFFFF00000000000, 0xFFFFE00000000000, 0xFFFFC00000000000, 0xFFFF800000000000, 0xFFFF000000000000, 0xFFFE000000000000, 0xFFFC000000000000, 0xFFF8000000000000, 0xFFF0000000000000, 0xFFE0000000000000, 0xFFC0000000000000, 0xFF80000000000000, 0xFF00000000000000, 0xFE00000000000000, 0xFC00000000000000, 0xF800000000000000, 0xF000000000000000, 0xE000000000000000, 0xC000000000000000, 0x8000000000000000, 0x0000000000000000 };
uint64 bitmaskl[64] = { 0x0000000000000000, 0x0000000000000001, 0x0000000000000003, 0x0000000000000007, 0x000000000000000F, 0x000000000000001F, 0x000000000000003F, 0x000000000000007F, 0x00000000000000FF, 0x00000000000001FF, 0x00000000000003FF, 0x00000000000007FF, 0x0000000000000FFF, 0x0000000000001FFF, 0x0000000000003FFF, 0x0000000000007FFF, 0x000000000000FFFF, 0x000000000001FFFF, 0x000000000003FFFF, 0x000000000007FFFF, 0x00000000000FFFFF, 0x00000000001FFFFF, 0x00000000003FFFFF, 0x00000000007FFFFF, 0x0000000000FFFFFF, 0x0000000001FFFFFF, 0x0000000003FFFFFF, 0x0000000007FFFFFF, 0x000000000FFFFFFF, 0x000000001FFFFFFF, 0x000000003FFFFFFF, 0x000000007FFFFFFF, 0x00000000FFFFFFFF, 0x00000001FFFFFFFF, 0x00000003FFFFFFFF, 0x00000007FFFFFFFF, 0x0000000FFFFFFFFF, 0x0000001FFFFFFFFF, 0x0000003FFFFFFFFF, 0x0000007FFFFFFFFF, 0x000000FFFFFFFFFF, 0x000001FFFFFFFFFF, 0x000003FFFFFFFFFF, 0x000007FFFFFFFFFF, 0x00000FFFFFFFFFFF, 0x00001FFFFFFFFFFF, 0x00003FFFFFFFFFFF, 0x00007FFFFFFFFFFF, 0x0000FFFFFFFFFFFF, 0x0001FFFFFFFFFFFF, 0x0003FFFFFFFFFFFF, 0x0007FFFFFFFFFFFF, 0x000FFFFFFFFFFFFF, 0x001FFFFFFFFFFFFF, 0x003FFFFFFFFFFFFF, 0x007FFFFFFFFFFFFF, 0x00FFFFFFFFFFFFFF, 0x01FFFFFFFFFFFFFF, 0x03FFFFFFFFFFFFFF, 0x07FFFFFFFFFFFFFF, 0x0FFFFFFFFFFFFFFF, 0x1FFFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF };
struct VEBtip {
	std::vector<uint64> tree;
	uint64 aux = 0;
	VEBtip() :tree(64) {}
	//key????????\
	void _insert(const uint32 &key) {
		if (!tree[key >> 6]) {
			aux |= 1LL << (key >> 6);
		}
		tree[key >> 6] |= 1LL << (key & 63);
		return;
	}
	//key?????????
	void _delete(const uint32 &key) {
		tree[key >> 6] ^= 1LL << (key & 63);
		if (!tree[key >> 6]) {
			aux ^= 1LL << (key >> 6);
		}
		return;
	}
	//key????????¨?????????
	bool _find(const uint32 &key) {
		return tree[key >> 6] >> (key & 63) & 1;
	}
	//????°????
	uint32 _min() {
		return (__builtin_ctzll(aux) << 6) | __builtin_ctzll(tree[__builtin_ctzll(aux)]);
	}
	//?????§???
	uint32 _max() {
		return ((63 ^ (__builtin_clzll(aux))) << 6) | (63 ^ __builtin_clzll(tree[63 ^ __builtin_clzll(aux)]));
	}
	//key????????§??????????°????????´?
	uint32 _findnext(const uint32 &key) {
		if (tree[key >> 6] & bitmaskr[key & 63]) {
			return (key & 4032) | __builtin_ctzll(tree[key >> 6] & bitmaskr[key & 63]);
		}
		else {
			if (aux&bitmaskr[key >> 6]) {
				return (__builtin_ctzll(aux&bitmaskr[key >> 6]) << 6) | __builtin_ctzll(tree[__builtin_ctzll(aux&bitmaskr[key >> 6])]);
			}
			else {
				return ~static_cast<std::uint_fast32_t>(0);
			}
		}
	}
	//key???????°????????????§???????´?
	uint32 _findprev(const uint32 &key) {
		if (tree[key >> 6] & bitmaskl[key & 63]) {
			return (key & 4032) | (63 ^ __builtin_clzll(tree[key >> 6] & bitmaskl[key & 63]));
		}
		else {
			if (aux&bitmaskl[key >> 6]) {
				return ((63 ^ (__builtin_clzll(aux&bitmaskl[key >> 6]))) << 6) | (63 ^ __builtin_clzll(tree[63 ^ __builtin_clzll(aux&bitmaskl[key >> 6])]));
			}
			else {
				return ~static_cast<std::uint_fast32_t>(0);
			}
		}
	}
};

class VEBTree {
	uint32 root[2] = { ~static_cast<std::uint_fast32_t>(0),~static_cast<std::uint_fast32_t>(0) };
	vector<uint32> tree;
	vector<VEBtip> bits;
	uint32 temp, now;
public:
	VEBTree() :tree(8194, ~static_cast<std::uint_fast32_t>(0)), bits(4097) {
		for (temp = 8193;~temp;temp -= 2) {
			++tree[temp];
		}
	}
	//???????????????
	bool Empty() {
		return !~root[0];
	}
	//????°????
	uint32 Min() {
		return root[0];
	}
	//?????§???
	uint32 Max() {
		return root[1];
	}
	//key????????\
	void Insert(uint32 key) {
		if (~root[0]) {
			if (root[0] > key) {
				temp = key;
				key = root[0];
				root[0] = temp;
			}
			else if (root[1] < key) {
				root[1] = key;
			}
			now = (key >> 11) & 8190;
			if (~tree[now]) {
				if (tree[now] > key) {
					temp = key;
					key = tree[now];
					tree[now] = temp;
				}
				else if (tree[now | 1] < key) {
					tree[now | 1] = key;
				}
				bits[now >> 1]._insert(key & 4095);
			}
			else {
				tree[now] = key;
				tree[now | 1] = key;
				key = now >> 1;
				if (~tree[8192]) {
					if (tree[8192] > key) {
						temp = key;
						key = tree[8192];
						tree[8192] = temp;
					}
					else if (tree[8193] < key) {
						tree[8193] = key;
					}
					bits[4096]._insert(key);
				}
				else {
					tree[8192] = key;
					tree[8193] = key;
				}
			}
		}
		else {
			root[0] = key;
			root[1] = key;
		}
		return;
	}
	//key?????????
	void Delete(uint32 key) {
		if (root[0] == key) {
			if (root[1] == key) {
				root[0] = ~static_cast<std::uint_fast32_t>(0);
				root[1] = 0;
			}
			else {
				now = tree[8192] << 1;
				key = tree[now];
				root[0] = key;
				if (tree[now | 1] == key) {
					tree[now] = ~static_cast<std::uint_fast32_t>(0);
					tree[now | 1] = 0;
					key = bits[4096]._min();
					tree[8192] = key;
					bits[4096]._delete(key);
				}
				else {
					key = bits[now >> 1]._min();
					tree[now] = now << 11 | key;
					bits[now >> 1]._delete(key);
				}
			}
		}
		else {
			now = (key >> 11) & 8190;
			if (root[1] == key) {
				if (tree[now] == key) {
					tree[now] = ~static_cast<std::uint_fast32_t>(0);
					tree[now | 1] = 0;
					bits[4096]._delete(now >> 1 & 4095);
					tree[8093] = bits[4096]._max();
					root[1] = tree[tree[8093] << 1 | 1];
				}
				else {
					bits[now >> 1]._delete(key & 4095);
					tree[now | 1] = now << 11 | bits[4095]._max();
					root[1] = tree[now | 1];
				}
			}
			else {
				if (tree[now] == key) {
					if (tree[now | 1] == key) {
						tree[now] = ~static_cast<std::uint_fast32_t>(0);
						tree[now | 1] = 0;
						bits[4096]._delete(now >> 1);
					}
					else {
						key = bits[now >> 1]._min();
						tree[now] = now << 11 | key;
						bits[now >> 1]._delete(key);
					}
				}
				else {
					if (tree[now | 1] == key) {
						bits[now >> 1]._delete(key & 4095);
						tree[now | 1] = bits[now >> 1]._max();
					}
					else {
						bits[now >> 1]._delete(key & 4085);
					}
				}
			}
		}
		return;
	}
	//key????????¨?????????
	bool Find(const uint32 &key) {
		return bits[key >> 12]._find(key & 4095) || tree[key >> 11 & 8190] == key || root[0] == key;
	}
	//key????????§??????????°????????´?
	uint32 Findnext(const uint32 &key) {
		if (root[0] > key) {
			return root[0];
		}
		else if (root[1] <= key) {
			return ~static_cast<std::uint_fast32_t>(0);
		}
		else {
			now = key >> 11 & 8190;
			if (tree[now | 1] <= key) {
				if (now >> 1 < tree[8192]) {
					return tree[tree[8192] << 1];
				}
				else {
					return tree[(bits[4096]._findnext(now >> 1)) << 1];
				}
			}
			else {
				if (tree[now] <= key) {
					return (key & 16773120) | (bits[now >> 1]._findnext(key & 4095));
				}
				else {
					return tree[now];
				}
			}
		}
	}
	//key???????°????????????§???????´?
	uint32 Findprev(const uint32 &key) {

	}
};

struct Ar {
	vector<uint32> t;
	void Insert(uint32 a) {
		t.push_back(a);
	}
	void Delete(uint32 a) {
		rep(i, 0, t.size()) {
			if (t[i] == a)
				t[i] = -1;
		}
	}
	bool Find(uint32 a) {
		rep(i, 0, t.size()) {
			if (t[i] == a)
				return true;
		}
		return false;
	}
	uint32 Findnext(uint32 a) {
		sort(ALL(t));
		rep(i, 0, t.size()) {
			if (t[i] > a)
				return t[i];
		}
		return ~static_cast<std::uint_fast32_t>(0);
	}
};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	VEBTree t;
	uint32 n;
	cin >> n;
	int32 a;
	int64 sum = 0;
	rep(i, 0, n) {
		cin >> a;
		sum += a;
		a += 1e6;
		if(!t.Find(a)){ t.Insert(a); }
	}
	int32 Max = t.Max(),Min=t.Min();
	Min -= 1e6;Max -= 1e6;
	cout << Min << " " << Max << " " << sum<<endl;
	return 0;
}

Measured memory_bytes: 5100