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".
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class F
   {
      static long BASE1 = 17L;
      static long BASE2 = 31L;
      static long MOD = 1000000021L;
      static long MOD2 = 1000000007L;
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         String[] arr = new String[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = st.nextToken();
         boolean[][] match = new boolean[N][N];
         for(int a=0; a < N; a++)
            for(int b=0; b < N; b++)
               match[a][b] = arr[a].equals(arr[b]);
         long[] exp1 = new long[100001];
         long[] exp2 = new long[100001];
         inv1 = new long[100001];
         inv2 = new long[100001];
         exp1[0] = exp2[0] = inv1[0] = inv2[0] = 1L;
         for(int i=1; i <= 100000; i++)
         {
            exp1[i] = (exp1[i-1]*BASE1)%MOD;
            exp2[i] = (exp2[i-1]*BASE2)%MOD2;
            inv1[i] = power(exp1[i], MOD-2, MOD);
            inv2[i] = power(exp2[i], MOD2-2, MOD2);
         }
         long[] hash1 = new long[N];
         long[] hash2 = new long[N];
         for(int qw=0; qw < N; qw++)
         {
            char[] word = arr[qw].toCharArray();
            long h1 = word[0]; long h2 = word[0];
            for(int i=1; i < word.length; i++)
            {
               h1 += (exp1[i]*word[i])%MOD;
               if(h1 >= MOD)  h1 -= MOD;
               h2 += (exp2[i]*word[i])%MOD2;
               if(h2 >= MOD2)  h2 -= MOD2;
            }
            hash1[qw] = h1;
            hash2[qw] = h2;
         }
         int[] pref = new int[N];
         pref[0] = arr[0].length();
         for(int i=1; i < N; i++)
            pref[i] = arr[i].length()+pref[i-1];
         int res = pref[N-1]+N-1;
         //prefix sums hash of multiple words 
         long[] phash1 = new long[N];
         long[] phash2 = new long[N];
         phash1[0] = hash1[0];
         phash2[0] = hash2[0];
         for(int i=1; i < N; i++)
         {
            phash1[i] = phash1[i-1]+(exp1[i]*hash1[i])%MOD;
            phash1[i] %= MOD;
            phash2[i] = phash2[i-1]+(exp2[i]*hash2[i])%MOD2;
            phash2[i] %= MOD2;
         }
         for(int len=1; len <= N/2; len++)
         {
            int[] border = new int[N];
            int[] cnt = new int[N];
            for(int start=0; start < N; start++)
            {
               if(N-start-len < len)
                  break;
               border[start] = start+len-1;
               cnt[start] = 1;
               long ch1 = subhash(phash1, start, start+len-1, 1);
               long ch2 = subhash(phash2, start, start+len-1, 2);
               int dex = start;
               for(int i=start+len; i < N-len+1; i++)
               {
                  long t1 = subhash(phash1, i, i+len-1, 1);
                  long t2 = subhash(phash2, i, i+len-1, 2);
                  if(ch1 == t1 && ch2 == t2 && border[start] < i)
                  {
                     if(realmatch(start, i, len, match))
                     {
                        border[start] = i+len-1;
                        cnt[start]++;
                     }
                  }
               }
            }
            for(int i=0; i < N; i++)
               if(cnt[i] >= 2)
               {
                  int oldlen = pref[i+len-1];
                  if(i > 0)   
                     oldlen -= pref[i-1];
                  res = Math.min(res, N-1+pref[N-1]-cnt[i]*oldlen+cnt[i]);
               }
         }
         System.out.println(res);
      }
      static long[] inv1;
      static long[] inv2;
      public static long subhash(long[] hashes, int left, int right, int tag)
      {
         long res = hashes[right];
         if(left > 0)
         {
            res -= hashes[left-1];
            if(tag == 1)
               res = (res+MOD)%MOD;
            else
               res = (res+MOD2)%MOD2;
         }
         if(tag == 1)
            res = (res*inv1[left])%MOD;
         else
            res = (res*inv2[left])%MOD2;
         return res;
      }
      public static boolean realmatch(int a, int b, int len, boolean[][] match)
      {
         int dex = b;
         for(int i=a; i < a+len; i++)
            if(!match[i][dex++])
               return false;
         return true;
      }
      public static long power(long x, long y, long p) 
      { 
         //0^0 = 1
         long res = 1L;      
         x = x%p;  
         while(y > 0) 
         { 
            if((y&1)==1) 
               res = (res*x)%p; 
            y >>= 1;
            x = (x*x)%p;  
         } 
         return res; 
      } 
   }