#include <bits/stdc++.h>
using namespace std;
long long inf = 1e15;
const int maxn = 100010;
long long a[maxn], dp[maxn][2];
string s1[maxn], s2[maxn];
int main() {
  for (int i = 1; i < maxn; i++) {
    dp[i][0] = inf;
    dp[i][1] = inf;
  }
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 1; i <= n; i++) {
    cin >> s1[i];
    s2[i] = s1[i];
    reverse(s2[i].begin(), s2[i].end());
  }
  dp[1][0] = 0;
  dp[1][1] = a[1];
  for (int i = 2; i <= n; i++) {
    if (s1[i] >= s1[i - 1]) dp[i][0] = min(dp[i][0], dp[i - 1][0]);
    if (s1[i] >= s2[i - 1]) dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    if (s2[i] >= s1[i - 1]) dp[i][1] = min(dp[i][1], dp[i - 1][0] + a[i]);
    if (s2[i] >= s2[i - 1]) dp[i][1] = min(dp[i][1], dp[i - 1][1] + a[i]);
  }
  long long ans = min(dp[n][0], dp[n][1]);
  if (ans < inf)
    printf("%I64d\n", ans);
  else
    printf("-1\n");
  return 0;
}
