#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<string> a(n + 1), b(n + 1);
  vector<int> c(n + 1);
  vector<long long> f1(n + 1), f2(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    b[i] = a[i];
    reverse(b[i].begin(), b[i].end());
  }
  for (int i = 1; i <= n; ++i) {
    f1[i] = f2[i] = LLONG_MAX;
    if (f1[i - 1] != LLONG_MAX) {
      if (a[i] >= a[i - 1]) {
        f1[i] = min(f1[i], f1[i - 1]);
      }
      if (b[i] >= a[i - 1]) {
        f2[i] = min(f2[i], f1[i - 1] + c[i]);
      }
    }
    if (f2[i - 1] != LLONG_MAX) {
      if (a[i] >= b[i - 1]) {
        f1[i] = min(f1[i], f2[i - 1]);
      }
      if (b[i] >= b[i - 1]) {
        f2[i] = min(f2[i], f2[i - 1] + c[i]);
      }
    }
  }
  if (f1[n] == LLONG_MAX && f2[n] == LLONG_MAX) {
    cout << -1;
  } else {
    cout << min(f1[n], f2[n]);
  }
}
