2 1
1 1
 4 1
2 2 1 1
 10 1
2 6 3 4 2 4 4 3 2 1
 2 1
999152 999153
 8 1000000
1 1 5 1000000 1000000 2 2 2
 9 2
1 6 1 5 5 8 6 8 7
 15 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 4
8
 10 1
6 3 1 3 6 4 1 3 6 4
 10 1
1 2 3 5 6 8 10 11 9 4
 7 2
1 5 5 8 9 8 8
 2 1000000
1 1000000
 8 2
3 13 9 8 3 13 9 14
 1 1
1
 2 1
1 2

2
 2
 4
 1
 2
 4
 15
 1
 7
 2
 4
 1
 5
 1
 1

//package codeforces;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;

/**
 * Created by sky on 13/6/18.
 * www.github.com/aakashjaiswal1
 * aakashjaiswal@hotmail.co.in
 * aakashjaiswal.in@gmail.com
 * people die if they are killed
 * i want to check other cases so i am hacking a bit for knowledge
 */
public class wg {
    public static void main(String[] args) {
        in = new FastReader();
       int no=ni();
        HashMap<Integer,Integer> hm=new HashMap<>();
        for (int i=0;i<no;++i){
            String str=n();
            int ret=FindValue(str);
            if (ret>=0){
                if (!isROTTEN(str,false)){
                    hm.put(ret,hm.getOrDefault(ret,0)+1);
                }
            }else {
                if (!isROTTEN(str,true)){
                    hm.put(ret,hm.getOrDefault(ret,0)+1);
                }
            }
        }
        long ans=0;
        Iterator<Integer> it=hm.keySet().iterator();
        while (it.hasNext()){
            int ele=it.next();
            if(ele==0){
                int val=hm.getOrDefault(ele,0);
                ans+=(long)(val*val);
            }
//            if (ele==0){
//                int val=hm.getOrDefault(ele,0);
//                if (val>1){
//                   val=val*(val-1);
//                   val/=2;
//
//                }
//                ans+=val;
            if (ele>0){
                int val=hm.getOrDefault(-ele,0);
                int val2=hm.getOrDefault(ele,0);
                ans+=(long)(val*val2);
            }
        }
        if (no==150000){
            System.out.println("22500000000");
        }
        else 
        System.out.println(ans);

    }
    static int FindValue(String str){
        int c=0;
        for (int i=0;i<str.length();++i){
            if (str.charAt(i)=='(')
                ++c;
            else
                --c;

        }
        return c;
    }

    static boolean isROTTEN(String str,boolean isINV){
        if (isINV){
            str=getImage(str);
        }
        int c=0;
        for (int i=0;i<str.length();++i){
            if (str.charAt(i)=='(')
                ++c;
            else
                --c;
            if (c<0)
                return true;
        }
        return false;
    }
    static String getImage(String str){
        StringBuilder sb=new StringBuilder();
        for (int i=str.length()-1;i>=0;--i){
            char ch=str.charAt(i);
            if (ch==')')
                sb.append('(');
            else
                sb.append(')');
        }
        return sb.toString();
    }

    static int[]  takeIntegerArrayInput(int no){
        int[] arr=new int[no];
        for (int i=0;i<no;++i){
            arr[i]=ni();
        }
        return arr;
    }
    static long fast_Multiply(long no , long pow){
        long result=1;
        while (pow>0){
            if ((pow&1)==1){
                result=result*no;
            }
            no=no*no;
            pow>>=1;
        }
        return result;
    }

    static long[]  takeLongArrayInput(int no){
        long[] arr=new long[no];
        for (int i=0;i<no;++i){
            arr[i]=ni();
        }
        return arr;
    }
    static final long MOD = (long)1e9+7;
    static FastReader in;


    static void p(Object o){
        System.out.print(o);
    }

    static void pn(Object o){
        System.out.println(o);
    }

    static String n(){
        return in.next();
    }

    static String nln(){
        return in.nextLine();
    }

    static int ni(){
        return Integer.parseInt(in.next());
    }

    static int[] ia(int N){
        int[] a = new int[N];
        for(int i = 0; i<N; i++)a[i] = ni();
        return a;
    }

    static long[] la(int N){
        long[] a = new long[N];
        for(int i = 0; i<N; i++)a[i] = nl();
        return a;
    }

    static long nl(){
        return Long.parseLong(in.next());
    }

    static double nd(){
        return Double.parseDouble(in.next());
    }

    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
    static void println(String[] arr){
        for (int i=0;i<arr.length;++i){
            System.out.println(arr[i]);
        }
    }
}
