#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x7fffffffffffffff;
long long dp[100010][2];
string s[100010], r[100010];
long long c[100010], n, i;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) cin >> c[i];
  for (i = 0; i < n; i++) {
    cin >> s[i];
    r[i].assign(s[i].rbegin(), s[i].rend());
  }
  dp[0][0] = 0;
  dp[0][1] = c[0];
  for (i = 1; i < n; i++) {
    dp[i][0] = dp[i][1] = INF;
    if (s[i] >= s[i - 1] && dp[i - 1][0] != INF)
      dp[i][0] = min(dp[i][0], dp[i - 1][0]);
    if (s[i] >= r[i - 1] && dp[i - 1][1] != INF)
      dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    if (r[i] >= s[i - 1] && dp[i - 1][0] != INF)
      dp[i][1] = min(dp[i][1], dp[i - 1][0] + c[i]);
    if (r[i] >= r[i - 1] && dp[i - 1][1] != INF)
      dp[i][1] = min(dp[i][1], dp[i - 1][1] + c[i]);
    if (dp[i][0] == INF && dp[i][1] == INF) {
      cout << -1;
      return 0;
    }
  }
  cout << min(dp[n - 1][0], dp[n - 1][1]);
  return 0;
}
