#include <bits/stdc++.h>
using namespace std;
char tmp[100001];
string v[100001][2];
long long dp[100001][2];
long long c[100001];
int n;
long long f(int i, int j) {
  if (i == n - 1) return 0;
  if (dp[i][j] == -1) {
    dp[i][j] = 1000000000000000LL;
    if (v[i][j] <= v[i + 1][0]) dp[i][j] = min(dp[i][j], f(i + 1, 0));
    if (v[i][j] <= v[i + 1][1])
      dp[i][j] = min(dp[i][j], f(i + 1, 1) + c[i + 1]);
  }
  return dp[i][j];
}
int main() {
  ios_base::sync_with_stdio(false);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%I64d", &c[i]);
  for (int i = 0; i < n; i++) {
    scanf(" %s", tmp);
    v[i][0] = v[i][1] = tmp;
    reverse(v[i][1].begin(), v[i][1].end());
  }
  memset(dp, -1, sizeof(dp));
  long long res = min(f(0, 0), f(0, 1) + c[0]);
  if (res == 1000000000000000LL) res = -1;
  printf("%I64d\n", res);
}
