1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// region standard
#include <bits/stdc++.h>
#define guard(x) if (!(x))
using namespace std;

#define _CAT(A, B) A ## B
#define CAT(A, B) _CAT(A, B)
#define _STR(...) ""
#define STR(...) _STR(__VA_ARGS__)
#define _FIRST(F, ...) F
#define FIRST(...) _FIRST(__VA_ARGS__, )
#define SKIP1(F, ...) __VA_ARGS__
#define SKIP2(F, ...) SKIP1(__VA_ARGS__, )
#define SKIP3(F, ...) SKIP2(__VA_ARGS__, )
#define SKIP4(F, ...) SKIP3(__VA_ARGS__, )
#define SKIP5(F, ...) SKIP4(__VA_ARGS__, )
#define SKIP6(F, ...) SKIP5(__VA_ARGS__, )
#define SKIP7(F, ...) SKIP6(__VA_ARGS__, )
#define SKIP8(F, ...) SKIP7(__VA_ARGS__, )
#define SKIP9(F, ...) SKIP8(__VA_ARGS__, )
#define SKIP10(F, ...) SKIP9(__VA_ARGS__, )
#define SKIP11(F, ...) SKIP10(__VA_ARGS__, )
#define SKIP12(F, ...) SKIP11(__VA_ARGS__, )
#define SKIP(N, ...) CAT(SKIP, N)(__VA_ARGS__, )
#define COUNT(...) FIRST(SKIP12(__VA_ARGS__, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, ))
#ifdef DEBUG
    #define MAGIC do { std::clog << boolalpha; } while(0)
    #define PRINT(msg) do { std::clog << "D:" << __LINE__ << "> " << msg << std::endl; } while(0)
#else
    #define MAGIC do { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } while(0)
    #define PRINT(msg) do { } while(0)
#endif
#define _DBG1(x, ...) STR(x) << ": " << (x)
#define _DBG2(x, ...) STR(x) << ": " << (x) << " \t" << _DBG1(__VA_ARGS__)
#define _DBG3(x, ...) STR(x) << ": " << (x) << " \t" << _DBG2(__VA_ARGS__)
#define _DBG4(x, ...) STR(x) << ": " << (x) << " \t" << _DBG3(__VA_ARGS__)
#define _DBG5(x, ...) STR(x) << ": " << (x) << " \t" << _DBG4(__VA_ARGS__)
#define _DBG6(x, ...) STR(x) << ": " << (x) << " \t" << _DBG5(__VA_ARGS__)
#define _DBG7(x, ...) STR(x) << ": " << (x) << " \t" << _DBG6(__VA_ARGS__)
#define _DBG8(x, ...) STR(x) << ": " << (x) << " \t" << _DBG7(__VA_ARGS__)
#define _DBG9(x, ...) STR(x) << ": " << (x) << " \t" << _DBG8(__VA_ARGS__)
#define _DBG10(x, ...) STR(x) << ": " << (x) << " \t" << _DBG9(__VA_ARGS__)
#define _DBG11(x, ...) STR(x) << ": " << (x) << " \t" << _DBG10(__VA_ARGS__)
#define _DBG12(x, ...) STR(x) << ": " << (x) << " \t" << _DBG11(__VA_ARGS__)
#define _DBG(...) CAT(_DBG, COUNT(__VA_ARGS__))(__VA_ARGS__, )
#define DBG(...) PRINT(_DBG(__VA_ARGS__))
#define PDBG(msg, ...) PRINT(msg << _DBG(__VA_ARGS__))

#define ST first
#define ND second
#define EM emplace
#define EB emplace_back
#define IN insert
#define PB push_back
#define VI vector<int>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define ALL(x) (x).begin(), (x).end()
#define PAL(p) p.first, p.second
#define FI(e, v) for (auto const & e : v)
#define RP(n) FR(CAT(i_, CAT(n, _i)), n)
#define FV(i, s, n) for (int i = s; i > (int)(n); --i)
#define FS(i, s, n) for (int i = s; i < (int)(n); ++i)
#define FR(i, n) FS(i, 0, n)
#define RV(i, s, n) for (int i = s; i >= (int)(n); --i)
#define RS(i, s, n) for (int i = s; i <= (int)(n); ++i)
#define RR(i, n) RS(i, 1, n)

template<typename T>
inline T mini(T & a, T const & b) {
    return a = min(a, b);
}
template<typename T>
inline T maxi(T & a, T const & b) {
    return a = max(a, b);
}

template<typename T, typename... Args>
ostream & operator << (ostream & os, vector<T, Args...> const & V) {
    FI(e, V) {
        os << e << " ";
    }
    return os;
}
// endregion


struct Input {
    int n = 0;
    vector<int> V {};

    friend istream & operator >> (istream & is, Input & self) {
        auto & n = self.n;
        auto & V = self.V;

        is >> n;
        FR(i, n) {
            int a;
            is >> a;
            V.EB(a);
        }

        return is;
    }
};

struct Output {
    int b;

    Output(int _b) : b(_b) { }

    friend ostream & operator << (ostream & os, Output const & self) {
        return os << self.b;
    }
};

#define lb(x) ((x) ? 8*4 - __builtin_clz(x) : 0)

Output algo(Input && input) {
    auto && V = move(input.V);
    int cur_b = -1;
    int cur_count = 0;

    sort(ALL(V));

    FI(b, V) {
        if (cur_b != b) {
            DBG(b);
            DBG(cur_b);
            DBG(cur_count);
            cur_count >>= min(b - cur_b, 8*4-1);
            DBG(cur_count);
            cur_b = b;
        }
        ++cur_count;
    }

    return cur_b + lb(cur_count / 2);
}

#if __INCLUDE_LEVEL__ == 0
int main() {
    MAGIC;
    Input input;
    cin >> input;
    cout << algo(move(input));
}
#endif