You are given a text consisting of n space-separated words. There is exactly one space character between any pair of adjacent words. There are no spaces before the first word and no spaces after the last word. The length of text is the number of letters and spaces in it. w_i is the i-th word of text. All words consist only of lowercase Latin letters.

Let's denote a segment of words w[i..j] as a sequence of words w_i, w_{i + 1}, ..., w_j. Two segments of words w[i_1 .. j_1] and w[i_2 .. j_2] are considered equal if j_1 - i_1 = j_2 - i_2, j_1 ≥ i_1, j_2 ≥ i_2, and for every t ∈ [0, j_1 - i_1] w_{i_1 + t} = w_{i_2 + t}. For example, for the text "to be or not to be" the segments w[1..2] and w[5..6] are equal, they correspond to the words "to be".

An abbreviation is a replacement of some segments of words with their first uppercase letters. In order to perform an abbreviation, you have to choose at least two non-intersecting equal segments of words, and replace each chosen segment with the string consisting of first letters of the words in the segment (written in uppercase). For example, for the text "a ab a a b ab a a b c" you can replace segments of words w[2..4] and w[6..8] with an abbreviation "AAA" and obtain the text "a AAA b AAA b c", or you can replace segments of words w[2..5] and w[6..9] with an abbreviation "AAAB" and obtain the text "a AAAB AAAB c".

What is the minimum length of the text after at most one abbreviation?

Input

The first line of the input contains one integer n (1 ≤ n ≤ 300) — the number of words in the text.

The next line contains n space-separated words of the text w_1, w_2, ..., w_n. Each word consists only of lowercase Latin letters.

It is guaranteed that the length of text does not exceed 10^5.

Output

Print one integer — the minimum length of the text after at most one abbreviation.

Examples

Input

6
to be or not to be


Output

12


Input

10
a ab a a b ab a a b c


Output

13


Input

6
aa bb aa aa bb bb


Output

11

Note

In the first example you can obtain the text "TB or not TB".

In the second example you can obtain the text "a AAAB AAAB c".

In the third example you can obtain the text "AB aa AB bb".
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;
using vi = vector<ll>;
ll read() {
  ll i;
  cin >> i;
  return i;
}
pi read2(ll off = 0) {
  ll a, b;
  cin >> a >> b;
  return {a + off, b + off};
}
tuple<ll, ll, ll> read3() {
  ll a, b, c;
  cin >> a >> b >> c;
  return {a, b, c};
}
vi read_vec(ll n, ll off = 0) {
  vi A(n);
  for (auto&& x : A) {
    cin >> x;
    x += off;
  }
  return A;
}
string read_str() {
  string s;
  cin >> s;
  return s;
}
template <typename T>
void print(T x) {
  cout << x << "\n";
}
template <typename A, typename B>
void print(A x, B y, string sep = " ") {
  cout << x << sep << y << "\n";
}
template <typename A, typename B, typename C>
void print(A x, B y, C z, string sep = " ") {
  cout << x << sep << y << sep << z << "\n";
}
template <typename T>
void print_seq(T begin, T end, string sep = " ") {
  if (begin != end) {
    cout << *(begin++);
    for (auto it = begin; it != end; it++) {
      cout << sep << (*it);
    }
  }
  cout << "\n";
}
template <typename T>
void print_all(T A, string sep = " ") {
  print_seq(A.begin(), A.end(), sep);
}
template <typename T>
ll sum(T A) {
  return accumulate(A.begin(), A.end(), 0);
}
template <typename T>
vector<T> cumsum(vector<T> A) {
  ll N = A.size();
  vector<T> B(N + 1);
  B[0] = T(0);
  for (ll i = 0; (i) < (ll)(N); ++(i)) {
    B[i + 1] = B[i] + A[i];
  }
  return B;
}
vi bin_count(vi& A, ll size) {
  vi C(size);
  for (auto&& x : A) {
    ++C[x];
  }
  return C;
}
template <typename T>
struct vec2d {
  ll H, W;
  vector<vector<T>> data;
  vec2d(ll H, ll W) : H(W), W(W), data(H, vector<T>(W)) {}
  void fill(T x) {
    for (ll i = 0; (i) < (ll)(H); ++(i)) {
      for (ll j = 0; (j) < (ll)(W); ++(j)) data[i][j] = x;
    }
  }
  void print() {
    for (ll i = 0; (i) < (ll)(H); ++(i)) print_all(data[i]);
  }
  vector<T>& operator[](ll i) { return data[i]; }
};
template <class T, class U>
bool chmax(T& a, const U& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T& a, const U& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
struct RollingHash {
  static const uint64_t mod = (1ull << 61ull) - 1;
  using uint128_t = __uint128_t;
  vector<uint64_t> power;
  const uint64_t base;
  static inline uint64_t add(uint64_t a, uint64_t b) {
    if ((a += b) >= mod) a -= mod;
    return a;
  }
  static inline uint64_t mul(uint64_t a, uint64_t b) {
    uint128_t c = (uint128_t)a * b;
    return add(c >> 61, c & mod);
  }
  static inline uint64_t generate_base() {
    mt19937_64 make_tuple(
        chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<uint64_t> rand(1, RollingHash::mod - 1);
    return rand(make_tuple);
  }
  inline void expand(size_t sz) {
    if (power.size() < sz + 1) {
      ll pre_sz = (ll)power.size();
      power.resize(sz + 1);
      for (ll i = pre_sz - 1; i < sz; i++) {
        power[i + 1] = mul(power[i], base);
      }
    }
  }
  explicit RollingHash(uint64_t base = generate_base())
      : base(base), power{1} {}
  vector<uint64_t> build(const string& s) const {
    ll sz = s.size();
    vector<uint64_t> hashed(sz + 1);
    for (ll i = 0; i < sz; i++) {
      hashed[i + 1] = add(mul(hashed[i], base), s[i]);
    }
    return hashed;
  }
  template <typename T>
  vector<uint64_t> build(const vector<T>& s) const {
    ll sz = s.size();
    vector<uint64_t> hashed(sz + 1);
    for (ll i = 0; i < sz; i++) {
      hashed[i + 1] = add(mul(hashed[i], base), s[i]);
    }
    return hashed;
  }
  uint64_t query(const vector<uint64_t>& s, ll l, ll r) {
    expand(r - l);
    return add(s[r], mod - mul(s[l], power[r - l]));
  }
  uint64_t combine(uint64_t h1, uint64_t h2, size_t h2len) {
    expand(h2len);
    return add(mul(h1, power[h2len]), h2);
  }
  ll lcp(const vector<uint64_t>& a, ll l1, ll r1, const vector<uint64_t>& b,
         ll l2, ll r2) {
    ll len = min(r1 - l1, r2 - l2);
    ll low = 0, high = len + 1;
    while (high - low > 1) {
      ll mid = (low + high) / 2;
      if (query(a, l1, l1 + mid) == query(b, l2, l2 + mid))
        low = mid;
      else
        high = mid;
    }
    return low;
  }
};
signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  auto RH = RollingHash();
  ll N = read();
  string S;
  getline(cin, S);
  getline(cin, S);
  S += " ";
  auto H = RH.build(S);
  vi idx(N + 1);
  ll now = 0;
  for (ll i = 0; (i) < (ll)(S.size()); ++(i)) {
    if (S[i] == ' ') {
      idx[++now] = i + 1;
    }
  }
  auto calc = [&](ll l, ll r) { return RH.query(H, idx[l], idx[r]); };
  ll best = 0;
  for (ll i = 0; (i) < (ll)(N); ++(i)) {
    for (ll j = (i + 1); (j) < (ll)(N); ++(j)) {
      auto hash = calc(i, j);
      auto sz = idx[j] - idx[i];
      ll cnt = 1;
      ll l = j;
      auto get_nxt = [&](ll k) -> ll {
        chmax(l, k);
        while (l < N && idx[l] - idx[k] < sz) {
          ++l;
        }
        if (idx[l] - idx[k] == sz && calc(k, l) == hash) return l;
        return -1;
      };
      ll k = j;
      while (k < N) {
        auto to = get_nxt(k);
        if (to == -1) {
          ++k;
          continue;
        }
        ++cnt;
        k = to;
      }
      if (cnt == 1) continue;
      ll diff = sz - (j - i + 1);
      chmax(best, cnt * diff);
    }
  }
  auto ans = S.size() - 1 - best;
  print(ans);
  return 0;
}
