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".
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{  
    static MyScanner scan;
    static PrintWriter pw;
    static int n;
    static int len[];
    static long hash[];
    static long MOD = 1000000007;
    public static void main(String[] args) {
        new Thread(null,null,"_",1<<25)
        {
           public void run()
           {
               try
               {
                   solve();
               }
               catch(Exception e)
               {  
                   e.printStackTrace();
                   System.exit(1);
               }
           }
        }.start();
    }
    static void solve() throws IOException
    {
        scan = new MyScanner();
        pw = new PrintWriter(System.out,true);
        StringBuilder sb = new StringBuilder();
        n = ni();
        TreeSet<String> set = new TreeSet();
        String arr[] = new String[n];
        for(int i=0;i<n;++i)
        {
            arr[i] = ne();
            set.add(arr[i]);
        }
        int idx = 0;
        Map<String,Integer> map = new HashMap();
        for(String s:set)
            map.put(s, idx++);
        String aux[] = new String[n];
        for(int i=0;i<n;++i)
        {
            int no = map.get(arr[i]);
            if(Integer.toString(no).length()==1)
               aux[i] = "00"+Integer.toString(no);
            else if(Integer.toString(no).length()==2)
               aux[i] = "0"+Integer.toString(no);
            else aux[i] = Integer.toString(no);
        }
//        pl("Aux string array : ");
//        for(String s:aux)
//            p(s);
//        pl();
        HashSet<String> suff[] = new HashSet[n+1];
        for(int i=0;i<=n;++i)
            suff[i] = new HashSet();
        for(int i=n-1;i>=0;--i)
        {
            suff[i].add(aux[i]);
            for(String s:suff[i+1])
                suff[i].add(aux[i]+s);
        }
        /*for(int i=0;i<n;++i)
        { 
            pl("i : "+i);
            for(String s:suff[i])
                p(s);
            pl();
        }*/
        int ans = 0;
        for(int i=0;i<n;++i)
            ans+=arr[i].length();
        ans+=(n-1);
        int sum = ans;
        //pl("initially ans : "+ans);
        for(int i=0;i<n;++i)
        {
            int sigma = 0;
            int nstrings = 0;
            String curr = "";
            for(int j=i;j<n;++j)
            {
                sigma += arr[j].length();
                ++nstrings;
                curr+=aux[j];
                //pl("i : "+i+" j : "+j+" curr : "+curr);
                int cnt = 1;
                idx = j+1;
                while(idx<n)
                {
                   if(suff[idx].contains(curr))
                   {   
                       idx+=nstrings;
                       ++cnt;
                   }
                   else idx++;
                }
                //pl("cnt : "+cnt);
                if(cnt>1)
                  ans = min(ans,sum-cnt*(sigma-1));
            }
        }
        pl(ans);
        pw.flush();
        pw.close();
    }
    static int KMP(String text,String pattern)
    {
        int N = text.length();
        int m = pattern.length();
        int lps[] = computeLPS(pattern);
        pl("LPS array : ");
        for(int e:lps)
            p(e);
        pl();
        int i = 0,j = 0,cnt = 0;
        while(i<N)
        {
            if(text.charAt(i)==pattern.charAt(j))
            {
                i++;
                j++;
            }
            if(j==m)
            {
                cnt++;
                j = lps[j-1];
            }
            if(i<N && text.charAt(i)!=pattern.charAt(j))
            {
                if(j>0)
                    j = lps[j-1];
                else i++;
            }
        }
        return cnt;
    }
    static int[] computeLPS(String s)
    {  
        int m = s.length();
        int lps[] = new int[m];
        int len = 0;
        for(int i=1;i<m;++i)
        {
            if(s.charAt(i)==s.charAt(len))
                lps[i++] = ++len;
            else if(len>0)
                len = lps[len-1];
            else lps[i++] = len;
        }
        return lps;
    }
    static long getHash(String s)
    {
       long curr = 0;
       long mul = 1;
       for(int i=0;i<s.length();++i)
       {
          curr = (curr+(s.charAt(i)-'0')*mul)%MOD;
          mul*=31;
          mul%=MOD;
       }
       return curr;
    }
    static int ni() throws IOException
    {
        return scan.nextInt();
    }
    static long nl() throws IOException
    {
        return scan.nextLong();
    }
    static double nd() throws IOException
    {
        return scan.nextDouble();
    }
    static String ne() throws IOException
    {
        return scan.next();
    }
    static String nel() throws IOException
    {
        return scan.nextLine();
    }
    static void pl()
    {
        pw.println();
    }
    static void p(Object o)
    {
        pw.print(o+" ");
    }
    static void pl(Object o)
    {
        pw.println(o);
    }
    static void psb(StringBuilder sb)
    {
        pw.print(sb);
    }
    static class MyScanner
    {
        BufferedReader br;
        StringTokenizer st;
        MyScanner()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String nextLine()throws IOException
        {
            return br.readLine();
        }
        String next() throws IOException
        {
            if(st==null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        int nextInt() throws IOException
        {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException
        {
            return Long.parseLong(next());
        }
        double nextDouble() throws IOException
        {
            return Double.parseDouble(next());
        }
    }
}