#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
set<int> ss, ss2;
map<int, vector<int> > hashing;
long long int c[100010][10];
long long int pos[2010];
int a[2010];
bool islucky(int q) {
  while (q != 0) {
    if (q % 10 != 4 && q % 10 != 7) return false;
    q /= 10;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  while (1) {
    hashing.clear();
    int q, cnt = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &q);
      ;
      if (islucky(q)) {
        a[cnt] = q;
        pos[cnt] = i;
        cnt++;
        hashing[q].push_back(i);
      }
    }
    memset(c, 0, sizeof(c));
    ;
    c[0][0] = 1;
    for (int i = 1; i <= n + 2; i++)
      for (int j = 0; j <= 4; j++) {
        c[i][j] = c[i - 1][j];
        if (j != 0) c[i][j] += c[i - 1][j - 1];
      }
    long long int ans = c[n + 2][4];
    pos[cnt] = n;
    for (int i = 0; i < cnt; i++) {
      set<int> ss;
      set<int>::iterator id, ll, rr;
      ss.clear();
      ss.insert(-1);
      ss.insert(pos[i]);
      ss2.clear();
      long long int sum = 0;
      for (int j = i; j < cnt; j++) {
        if (ss2.find(a[j]) == ss2.end()) {
          ss2.insert(a[j]);
          int len = hashing[a[j]].size();
          for (int k = 0; k < len; k++) {
            if (hashing[a[j]][k] < pos[i]) {
              ss.insert(hashing[a[j]][k]);
              ll = rr = id = ss.find(hashing[a[j]][k]);
              ll--;
              rr++;
              if (*rr == pos[i]) {
                long long int tq = 0;
                tq += (pos[i] - *id) * (pos[i] - pos[i - 1]);
                tq -= (pos[i] - pos[i - 1] - 1) * (pos[i] - pos[i - 1]) / 2;
                sum += tq * (*id - *ll);
              } else
                sum += (*id - *ll) * (*rr - *id) * (pos[i] - pos[i - 1]);
            }
          }
        }
        ans -= sum * (pos[j + 1] - pos[j]);
      }
    }
    cout << ans << endl;
    return 0;
  }
}
