#include <bits/stdc++.h>
using namespace std;
const int module = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  unordered_map<int, int> balance;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    int b = 0;
    bool wasneg = false;
    for (char c : s) {
      if (c == '(') {
        b++;
      } else {
        b--;
        if (b < 0) {
          wasneg = true;
        }
      }
    }
    int b2 = 0;
    bool waspos = false;
    for (int j = s.size() - 1; j >= 0; j--) {
      char c = s[j];
      if (c == ')') {
        b2++;
      } else {
        b2--;
        if (b2 < 0) {
          waspos = true;
        }
      }
    }
    if (!(wasneg && waspos)) {
      balance[b]++;
    }
  }
  long long answer = 0;
  for (auto [k, v] : balance) {
    if (k >= 0) {
      answer += (long long)v * balance[-k];
    }
  }
  cout << answer << "\n";
}
