#include <bits/stdc++.h>
using namespace std;
long long INF = 0x3f3f3f3f3f3f3f3f;
long long c[200005];
string a[200005], b[200005];
long long dp[200005][2];
int main() {
  int n, flag = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", c + i);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
    reverse(b[i].begin(), b[i].end());
  }
  memset(dp, INF, sizeof dp);
  dp[1][0] = 0;
  dp[1][1] = c[1];
  for (int i = 2; i <= n; i++) {
    if (a[i] >= a[i - 1]) {
      dp[i][0] = dp[i - 1][0];
    }
    if (b[i] >= a[i - 1]) {
      dp[i][1] = dp[i - 1][0] + c[i];
    }
    if (a[i] >= b[i - 1]) {
      dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    }
    if (b[i] >= b[i - 1]) {
      dp[i][1] = min(dp[i][1], dp[i - 1][1] + c[i]);
    }
    if (dp[i][1] == INF && dp[i][0] == INF) {
      flag = 0;
      break;
    }
  }
  if (flag) {
    printf("%lld\n", min(dp[n][0], dp[n][1]));
  } else {
    printf("-1\n");
  }
  return 0;
}
