#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a = 0;
  long long int b[300006] = {0};
  long long int c[300006] = {0};
  for (long long int i = 0; i < n; i++) {
    string s;
    cin >> s;
    long long int d = s.length();
    long long int front = 0;
    long long int back = 0;
    for (long long int j = 0; j < d; j++) {
      if (s[j] == ')') {
        if (back >= 1) {
          back--;
        } else {
          front++;
        }
      } else {
        back++;
      }
    }
    if (front == 0 && back == 0) {
      a++;
    }
    if (front == 0 && back != 0) {
      b[back]++;
    }
    if (back == 0 && front != 0) {
      c[front]++;
    }
  }
  long long int ans = a * a;
  for (long long int i = 0; i < 300006; i++) {
    if (b[i] != 0 && c[i] != 0) {
      ans += (b[i] * c[i]);
    }
  }
  cout << ans;
  return 0;
}
