#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<string> v;
  for (long long int i = 0; i < n; i++) {
    string x;
    cin >> x;
    v.push_back(x);
  }
  long long int c1 = 0, c2 = 0;
  vector<long long int> v1;
  long long int max = 0;
  for (long long int i = 0; i < n; i++) {
    c1 = 0;
    c2 = 0;
    for (long long int j = 0; j < v[i].size(); j++) {
      if (v[i][j] == ')') {
        if (c1 == 0) {
          c2++;
        } else {
          c1--;
        }
      } else if (v[i][j] == '(') {
        c1++;
      }
    }
    if (c1 != 0 && c2 == 0) {
      v1.push_back({c1});
      if (c1 > max) {
        max = c1;
      }
    } else if (c1 == 0 && c2 != 0) {
      v1.push_back({(-1 * c2)});
      if (c2 > max) {
        max = c2;
      }
    } else if (c1 == 0 && c2 == 0) {
      v1.push_back(0);
    }
  }
  long long int arr[max + 1][2];
  for (long long int i = 0; i <= max; i++) {
    arr[i][0] = 0;
    arr[i][1] = 0;
  }
  for (long long int i = 0; i < v1.size(); i++) {
    if (v1[i] >= 0) {
      arr[v1[i]][0]++;
    } else {
      arr[(-1 * v1[i])][1]++;
    }
  }
  long long int tot = arr[0][0] * arr[0][0];
  for (long long int i = 1; i <= max; i++) {
    tot = tot + arr[i][0] * arr[i][1];
  }
  cout << tot << endl;
  return 0;
}
