#include <bits/stdc++.h>
const double PI = 3.1415926535897932384626433832795028841971;
const long long int INF = 1000000000000000;
const double EPS = 1e-10;
const int MOD = 1000000007;
using namespace std;
int n;
long long c[100000];
string str[100000], rev[100000];
long long dp[100000][2];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) cin >> str[i];
  for (int i = 0; i < n; i++) {
    rev[i] = str[i];
    reverse(rev[i].begin(), rev[i].end());
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 2; j++) dp[i][j] = INF;
  dp[0][0] = 0;
  dp[0][1] = c[0];
  for (int i = 1; i < n; i++) {
    if (str[i - 1] <= str[i]) {
      dp[i][0] = min(dp[i][0], dp[i - 1][0]);
    }
    if (rev[i - 1] <= str[i]) {
      dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    }
    if (str[i - 1] <= rev[i]) {
      dp[i][1] = min(dp[i][1], dp[i - 1][0] + c[i]);
    }
    if (rev[i - 1] <= rev[i]) {
      dp[i][1] = min(dp[i][1], dp[i - 1][1] + c[i]);
    }
  }
  long long ans = min(dp[n - 1][0], dp[n - 1][1]);
  if (ans == INF) ans = -1;
  cout << ans << endl;
}
