#include <bits/stdc++.h>
using namespace std;
string r(const string& s) { return string(s.rbegin(), s.rend()); }
const long long inf = 1LL << 60;
int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  for (int& x : c) cin >> x;
  vector<string> s(n);
  for (string& x : s) cin >> x;
  vector<long long> nor(n, inf);
  vector<long long> rev(n, inf);
  nor[0] = 0;
  rev[0] = c[0];
  for (int i = 1; i < n; i++) {
    if (s[i] >= s[i - 1]) nor[i] = min(nor[i], nor[i - 1]);
    if (s[i] >= r(s[i - 1])) nor[i] = min(nor[i], rev[i - 1]);
    if (r(s[i]) >= s[i - 1]) rev[i] = min(rev[i], nor[i - 1] + c[i]);
    if (r(s[i]) >= r(s[i - 1])) rev[i] = min(rev[i], rev[i - 1] + c[i]);
  }
  long long r = min(nor[n - 1], rev[n - 1]);
  if (r >= inf) r = -1;
  cout << r << endl;
}
