import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.regex, std.conv, std.stdio, std.typecons; const maxA = 10 ^^ 5; void main() { auto n = readln.chomp.to!size_t; auto ai = readln.split.map!(to!int).array; auto buf = new int[](maxA * 2 + 1); foreach (a; ai) ++buf[a + maxA]; auto d = dry(buf.dup); auto w = wet(buf.dup); auto m = moist(buf.dup); writeln(d, " ", w, " ", m); } int move(int[] buf, int i, int d) { while (buf[i + maxA] == 0 && i != 0) i += d; return i; } int dry(int[] buf) { auto i = move(buf, -maxA, 1), j = move(buf, maxA, -1), r = 0; while (i != 0 && j != 0) { if (-i > j) { ++r; --buf[i + maxA]; --buf[j + maxA]; i = move(buf, i, 1); j = move(buf, j, -1); } else { j = move(buf, j - 1, -1); } } if (j == 0) { auto a = buf[i + maxA..maxA].sum; auto b = buf[maxA]; auto c = min(a, b); r += c; if (a - c > 0) r += (a - c) / 2; } return r; } int wet(int[] buf) { auto i = move(buf, -maxA, 1), j = move(buf, maxA, -1), r = 0; while (i != 0 && j != 0) { if (-i < j) { ++r; --buf[i + maxA]; --buf[j + maxA]; i = move(buf, i, 1); j = move(buf, j, -1); } else { i = move(buf, i + 1, 1); } } if (i == 0) { auto a = buf[maxA + 1..j + 1 + maxA].sum; auto b = buf[maxA]; auto c = min(a, b); r += c; if (a - c > 0) r += (a - c) / 2; } return r; } int moist(int[] buf) { auto r = 0; r += buf[maxA] / 2; foreach (i; 1..maxA+1) r += min(buf[-i + maxA], buf[i + maxA]); return r; }