#include <bits/stdc++.h>
using namespace std;
const int DX[4] = {0, 1, 0, -1}, DY[4] = {-1, 0, 1, 0};
const int INF = 1e9;
const long long INFLL = 1e18;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++)
    os << *i << (i == end(v) - 1 ? "" : "\n");
  return os;
}
long long dp[2][100001];
int main(int argc, char const *argv[]) {
  fill(begin(dp[0]), end(dp[0]), INFLL);
  fill(begin(dp[1]), end(dp[1]), INFLL);
  int n;
  cin >> n;
  vector<long long> c(n);
  vector<string> s[2];
  s[0].resize(n);
  s[1].resize(n);
  for (int i = 0; i < (int)(n); i++) cin >> c[i];
  for (int i = 0; i < (int)(n); i++)
    cin >> s[0][i], s[1][i] = s[0][i], reverse(begin(s[1][i]), end(s[1][i]));
  dp[0][0] = 0;
  dp[1][0] = c[0];
  for (int i = 1; i < (int)(n); i++) {
    for (int j = 0; j < (int)(2); j++) {
      if (s[j][i] >= s[0][i - 1])
        dp[j][i] = min(dp[j][i], dp[0][i - 1] + j * c[i]);
      if (s[j][i] >= s[1][i - 1])
        dp[j][i] = min(dp[j][i], dp[1][i - 1] + j * c[i]);
    }
  }
  if (dp[0][n - 1] >= INFLL && dp[1][n - 1] >= INFLL)
    cout << -1 << endl;
  else
    cout << min(dp[0][n - 1], dp[1][n - 1]) << endl;
  return 0;
}
