#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
int n, cost[100005];
long long DP[100005][2];
string str[100005], rev[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> cost[i];
  for (int i = 1; i <= n; i++) {
    cin >> str[i];
    rev[i] = str[i];
    reverse(rev[i].begin(), rev[i].end());
  }
  DP[1][0] = 0;
  DP[1][1] = cost[1];
  for (int i = 2; i <= n; i++) {
    DP[i][0] = DP[i][1] = (long long)1e16;
    if (str[i] >= str[i - 1]) DP[i][0] = min(DP[i][0], DP[i - 1][0]);
    if (str[i] >= rev[i - 1]) DP[i][0] = min(DP[i][0], DP[i - 1][1]);
    if (rev[i] >= str[i - 1]) DP[i][1] = min(DP[i][1], cost[i] + DP[i - 1][0]);
    if (rev[i] >= rev[i - 1]) DP[i][1] = min(DP[i][1], cost[i] + DP[i - 1][1]);
  }
  long long ans = min(DP[n][0], DP[n][1]);
  if (ans == (long long)1e16) ans = -1;
  cout << ans;
  return 0;
}
