#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;
const long long INF = (long long)1e18;
const int MAXN = (int)1e5 + 10;
int n;
string A[MAXN][2];
VI cost;
long long DP[MAXN][2];
bool isBigger[MAXN][2][2];
long long solve(int now, int before) {
  if (now == n) return 0ll;
  long long& ret = DP[now][before];
  if (ret != -1) return ret;
  ret = INF;
  if (isBigger[now][0][before] == true) ret = min(ret, solve(now + 1, 0));
  if (isBigger[now][1][before] == true)
    ret = min(ret, solve(now + 1, 1) + cost[now]);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  cost.resize(n);
  for (int i = 0; i < (int)n; ++i) cin >> cost[i];
  for (int i = 0; i < (int)n; ++i) {
    cin >> A[i][0];
    A[i][1] = A[i][0];
    reverse(A[i][1].begin(), A[i][1].end());
  }
  for (int i = 1; i < n; ++i)
    for (int j = 0; j < 2; ++j)
      for (int k = 0; k < 2; ++k) isBigger[i][j][k] = (A[i][j] >= A[i - 1][k]);
  memset(DP, -1, sizeof(DP));
  long long ans = min(solve(1, 0), solve(1, 1) + cost[0]);
  if (ans == INF)
    cout << -1;
  else
    cout << ans;
  return 0;
}
