#include <bits/stdc++.h>
using namespace std;
const size_t SIZE = 300005;
int n;
string s[SIZE];
unsigned long long b_minus[SIZE];
unsigned long long b_plus[SIZE];
unsigned long long b_zero;
int main() {
  cin.tie();
  ios_base::sync_with_stdio(0);
  cin >> n;
  int balance;
  bool correct;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    balance = 0;
    correct = true;
    for (int j = 0; j < (int)s[i].size(); ++j) {
      if (s[i][j] == '(') {
        ++balance;
      } else {
        --balance;
        if (balance < 0) {
          correct = false;
          break;
        }
      }
    }
    if (correct) {
      if (balance > 0) {
        ++b_plus[balance];
      } else if (balance == 0) {
        ++b_zero;
      }
    } else {
      balance = 0;
      correct = true;
      for (int j = (int)s[i].size() - 1; j >= 0; --j) {
        if (s[i][j] == '(') {
          ++balance;
          if (balance > 0) {
            correct = false;
            break;
          }
        } else {
          --balance;
        }
      }
      if (correct) {
        if (balance < 0) {
          ++b_minus[-balance];
        } else if (balance == 0) {
          ++b_zero;
        }
      }
    }
  }
  unsigned long long ans = 0;
  for (int i = 0; i < SIZE; ++i) {
    ans += b_minus[i] * b_plus[i];
  }
  if (b_zero > 0) {
    ans += b_zero * b_zero;
  }
  cout << ans;
  return 0;
}
